Live data from Hacker News

Trains in Switzerland are not allowed to have 256 axles

twitter.com

71–80 of 92 posts

Re: Trains in Switzerland are not allowed to have 256 axles

#71
post #67
post #65

That's nothing. Signed overflow in C/C++ is _undefined behavior_. Which means there's no guarantee that you'll get anything recognizable out of it. :-)

But unsigned overflow is defined. Are we expecting a negative number of axles?

The train counter isn't even software based. I just wanted to point out the example of a much more common issue that most programmers aren't aware of. Very few languages catch unsigned integer overflow as well. The only popular one I can name is Swift.

Re: Trains in Switzerland are not allowed to have 256 axles

#72
post #63

Earlier quoted context omitted.

Signed numbers are preferred. Imaging you try to buy something checking if the remaining balance would be greater than zero is pretty much guaranteed, resulting in 4+ billion instead. Signed number (just 64bit) is the correct number type for such operations.

Pushing it off to the negatives does not solve the issue of overflow.

[deleted]

Re: Trains in Switzerland are not allowed to have 256 axles

#73
post #63

Earlier quoted context omitted.

Signed numbers are preferred. Imaging you try to buy something checking if the remaining balance would be greater than zero is pretty much guaranteed, resulting in 4+ billion instead. Signed number (just 64bit) is the correct number type for such operations.

Pushing it off to the negatives does not solve the issue of overflow.

> Pushing it off to the negatives does not solve the issue of overflow.

it allows for comparison with errors. Working with unsigned numbers is error prone... and I started with 6502 that didn't have signed numbers.

The idea is preventing the overflow by being able to check for negatives easily. Having negative gold is likely better than leaving someone with 4billons of. For instance stuff like "max(0, balance)" just doesn't work with unsigned ones.

Re: Trains in Switzerland are not allowed to have 256 axles

#74
post #33

Earlier quoted context omitted.

Or, you know, infrared cameras :)

Or just more light , and focus on shooting the dark spots.

Or just _more_ light, and you don’t need to shoot because everything vantablack will be aflame...

Re: Trains in Switzerland are not allowed to have 256 axles

#75

Earlier quoted context omitted.

Or just more light , and focus on shooting the dark spots.

Or just _more_ light, and you don’t need to shoot because everything vantablack will be aflame...

What if we tried more power?

https://what-if.xkcd.com/13/

Re: Trains in Switzerland are not allowed to have 256 axles

#76
post #51

Earlier quoted context omitted.

I would wager that they might be as meticulous in Japan too.

I’m glad I read an article on HN about pointing and calling[0] in the Japanese rail system as a way of preventing accidents. I take a blood pressure medication and had once or twice taken it a second time in the day, which wiped me out and made it VERY difficult to work (for the record, I don’t take it for blood pressure and it’s a very low dose, so I wasn’t at risk of my heart stopping, just very sleepy). Now I do a…

That's a good trick. I've heard about it before but never thought to apply it to my own life. There's a lot of everyday mindless tasks that are easy to forget you've done them.

I should start doing it with shampoo when I shower.

Re: Trains in Switzerland are not allowed to have 256 axles

#77

I'm waiting for the freak accident when a 200-axle train enters a given segment, and then later a 56-axle train accidentally ignores a red light, and plop the segment is now marked as all-clear again.

allowing for not just two but three trains in a given section... wow!

Re: Trains in Switzerland are not allowed to have 256 axles

#78
post #48
post #44

Earlier quoted context omitted.

What if Swiss trains consist of 30-40 cars at most? Then the rule is purely technical and doesn't even have to be remembered.

Actually, the longest regular Swiss trains seem to top out at 44 cars. This is because of passing siding lengths being much smaller than other countries such as the US. There are longer trains that are scheduled on routes with longer sidings however such as a the main north/south routes. Most European trains rarely exceed 22 cars for the same reasons as they have to be able to be passed by express trains in stations.

but if most of the cars have 8 axles per wagon, they'll hit 256 pretty easily. I don't know how many freight wagons have that many axles, but a lot of passenger carriges do.

Re: Trains in Switzerland are not allowed to have 256 axles

#79
post #69

Earlier quoted context omitted.

Some people just really, really dislike unsigned ints.

I've run into programmers that think something terrible is going to happen if you use an unsigned int for anything.

Is there a popular language these days that throws an exception whenever an unsigned int overflows?

Re: Trains in Switzerland are not allowed to have 256 axles

#80
post #69

Earlier quoted context omitted.

I've run into programmers that think something terrible is going to happen if you use an unsigned int for anything.

Is there a popular language these days that throws an exception whenever an unsigned int overflows?

Rust in debug mode or with a compiler option will panic if a number overflows.
Post reply on HN