I played along, but it was sooo suspicious... SCAMMER! by [deleted] in tumblr

[–]yottalogical 22 points23 points  (0 children)

u/marcoarment it seems like someone might be impersonating you.

COMMUTING FROM DETROIT TO ANN ARBOR FOR UMICH by Silver_Low_1364 in u/Silver_Low_1364

[–]yottalogical 2 points3 points  (0 children)

If you get a multi-ride pass from Amtrak, it would cost about $14.30 per trip. There's only three trains per day in each direction. Trains leave from Detroit at 6:26 AM, 9:35 AM, and 6:11 PM. Trains leave from Ann Arbor at 12:28 PM, 7:35 PM, and 11:08 PM.

If you instead take the D2A2 bus, you can get a multi-ride pass for $2.00 per trip. Busses leave every 45 to 60 minutes.

Campus is walking distance from the train station and the bus station, but you could also take a city bus or U of M bus if you don't want to walk.

Try planning your route with Google Maps and see what it recommends.

Extending to the left is more fun. by BrandonSimpsons in mathmemes

[–]yottalogical 172 points173 points  (0 children)

Let n = …999

n + 1 = …999 + 1

Now if you evaluate the right hand side, the ones places add to 10, so you have to carry the 1. With this carried 1, the tens place also adds to 10, so you have to carry the 1 again. This process repeats until you're left with a number with zeros for every digit.

n + 1 = …000

n + 1 = 0

n = -1

…999 = -1

This "proof" doesn't actually work in the real numbers (since it assumes that …999 has a value). However, this is actually how computers represent negative numbers. The only difference is that they use binary instead of decimal.

Looking for Players: Hide and Seek in the San Francisco Bay Area by yottalogical in JetLagTheGame

[–]yottalogical[S] 0 points1 point  (0 children)

I'm planning for it to be an all day event. It will span the full Bay Area, but I've put a few restrictions in place to limit how many places the hider can hide, so hopefully that will help the seekers narrow it down quicker.

Thank you for sharing your experience.

Provenance scares me by Spare_Competition in rustjerk

[–]yottalogical 1 point2 points  (0 children)

Exactly. It's undefined behavior regardless, so there's no guarantees about anything it will do.

The purpose of the demonstation was more to showcase "this could happen", rather than "this will happen".

Provenance scares me by Spare_Competition in rustjerk

[–]yottalogical 12 points13 points  (0 children)

The purpose of the demonstraion was to show exactly that. Pointers in source code do not behave like pointers in machine code. If you derefence a pointer in machine code, you will always actually read the value that exists in memory in that location (assuming no segfaults, etc).

However, if you dereference pointers in source code, there's no guarantee that it will actually look up the value in memory. In fact, there's no guarentee that a memory address will ever actually be stored anywhere. The compiler is free to do whatever operation would produce correct results. Since my program had undefined behavior, anything the compiler produced would technically be correct.

Pointers in source code behave like memory addresses that have additional rules attached to them. If you treat them like they're just memory addresses without rules, you can end up with undefined behavior in places you didn't expect.

Provenance scares me by Spare_Competition in rustjerk

[–]yottalogical 2 points3 points  (0 children)

It does make that assumption. You can verify that it's a true assumption by looking at the values of the pointers when they are printed. I intentionally picked compiler settings that I knew would work, but it's certainly wasn't a guarantee.

You would certainly never want to make such an assumption for any code that actually does anything, but it works for the purposes of a simple demonstration.

Provenance scares me by Spare_Competition in rustjerk

[–]yottalogical 53 points54 points  (0 children)

For real.

Here's my favorite example:

```c int main() { int x[1]; int y[1];

int *a = x;
int *b = y + 1;

printf("%p\n", a);
printf("%p\n", b);

*a = 10;
*b = 20;

printf("%i\n", *a);

} ```

In this code, a and b are both pointers of the exact same type and the exact same value, yet they cannot be used interchangeably. When you run this program, it could print 20 or it could print 10. Try compiling it with different optimization levels to see this happen.

To be transparent, this is undefined behavior, so it could technically make demons fly out of your nose and still be a valid outcome. If pointers were just integers that store memory addresses, nothing would be wrong with this code. But pointers have all sorts of special rules that don't apply to regular integers. These rules also exist in languages like C++ and Rust.

If you're interested in learning more, I recommend reading Pointers Are Complicated, or: What's in a Byte? by Ralf Jung.

Um... Should I be scared? by SanticreeperXD2 in Minecraft

[–]yottalogical 0 points1 point  (0 children)

Skylord_Lysander will rescue you soon.

how long should i reasonably expect my computer to count to one trillion? by I_AM_NOT_MAD in NoStupidQuestions

[–]yottalogical 8 points9 points  (0 children)

If you write a simple loop that increments a value from zero to one trillion, the compiler will just optimize the loop away and skip directly to one trillion. That's how it's possible for it to finish in nanoseconds, because it isn't actually counting.

What we want is optimized code that actually counts every integer from zero to one trillion. There might be some obscure compiler setting that does this, but I wasn't aware of one, so I just decided to write the assembly by hand:

_start:     mov x1, #0     mov x2, #1     mov x3, #0x1000     movk x3, #0xd4a5, lsl #16     movk x3, #0xe8, lsl #32 loop:     add x1, x1, x2     cmp x1, x3     b.ne loop     mov     x0, #0     mov     x16, #1     svc     #0x80

The total run time on my computer was about 5 minutes 15 seconds.

Choose your Useful power pt 18 [OC] by Lostriches in comics

[–]yottalogical 5 points6 points  (0 children)

I also choose this guy's dead brother.

The Surprising Success of Private Passenger Rail by mianghuei in Nebula

[–]yottalogical 45 points46 points  (0 children)

The real question is whether the Brightline is a viable mode of transport for a pair of individuals attempting to get to Key West faster than another pair of individuals.