Live data from Hacker News

Trains in Switzerland are not allowed to have 256 axles

twitter.com

81–90 of 92 posts

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

#81

Earlier quoted context omitted.

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.

Huh. That doesn't sound like something people use in production code. Maybe a hardware feature is needed? I mean, it's normal with floating point to handle overflow in a more sensible way, isn't it...

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

#82
post #2

To save you the click through: > This may be a great obscure fact, but it is not an example of European regulations gone mad. To keep track of where all the trains are on the Swiss rail network, there are detectors positioned around the rails. They are simple detectors that are activated when a wheel goes over a rail, and they count how many wheels there are to provide some basic information about the train which has…

Bureaucracy fixing software issues is quite common. One story i have heard is that in the early days of railway reservation computerization in India, there were storage issues on the servers. The solution : cut the advance booking time from 90 days to 45, where it stayed for many years.

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

#83

Earlier quoted context omitted.

Rust in debug mode or with a compiler option will panic if a number overflows.

Huh. That doesn't sound like something people use in production code. Maybe a hardware feature is needed? I mean, it's normal with floating point to handle overflow in a more sensible way, isn't it...

There are safe operation extensions like "save add", "save mul" for numbers in Rust which would detect overflows, but you'd have a drawback as it won't return just the number (of type u64, for example), it would return result and you'd be forced to handle it.

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

#84
post #48

Earlier quoted context omitted.

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.

I am somewhat interested in railways, but I have never seen an 8 axle passenger wagon. Even 6 axle passenger wagons are not in use in Europe today. Can you give a reference of any 8 axle wagon? The longest passenger trains in Central Europe are around 400 meters. To get 256 axles there would be an axle every 1.6 meters on the whole train.

Freight trains of 1000 meters are exceptional in Europe. You would need an axle every 4 meters to come up to 256.

The axle limit is completely theoretical. The are plenty of other limits a train would exceed before.

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

#85
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?

I think you can specify 'checked' in C# which will result in an exception on overflow.

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

#86

The thing is Switzerland is also the only country where I could imagine someone might know such a rule. Say you are working on connecting some trains, and you happen to be one car away from 256 axles. Well, if the org you're working for is SBB/CFF/FFS I could totally imagine the foreman saying "oh wait, there's a rule about this". Any other country, no way. From personal experience people there seem to follow the rul…

The rule would manifest itself in some sort of control in the train design/assembly systems, which would forbid a combination of wagons totalling 256 axles. That way, the issue would never reach the shunters who actually assemble the train, as the list they receive would always avoid that situation.

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

#87
post #47

Earlier quoted context omitted.

Yep. They routinely run fairly long trains over the Lotschberg and Gotthard lines through the base tunnels that I’m pretty certain are approaching 256 axles, but I have yet to see any with more. Most likely the main transalpine lines now allows >256 axles while other secondary lines have not been upgraded.

Trains longer than 256 aren't the issue as the numbers roll over. The problem is trains with exactly 256 axles (or a multiple of 256), they're seen as zero.

Not an expert, but I imagine it could still cause some routing problems if a 258-axle train were mis-registered as a 2-axle train; the latter takes up dramatically more space on the network.

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

#88
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.

If the domain is known to be positive, you can use the sign bit as an overflow flag.

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

#89

Earlier quoted context omitted.

Rust in debug mode or with a compiler option will panic if a number overflows.

Huh. That doesn't sound like something people use in production code. Maybe a hardware feature is needed? I mean, it's normal with floating point to handle overflow in a more sensible way, isn't it...

There's also functions which people do use to specify specific behaviour no matter the release mode, where handling overflows properly is particularly important - e.g. cryptography-related code.

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

#90

TIL: Per the article, this 256 limitation also applies to number of users in WhatsApp conversations and the maximum block height of a Minecraft world.

I understand why an 8 bit number would be used for counting...

But that limitation makes no sense for WhatsApp user limit count. Presumably every user has an id number identifying them (maybe a long integer). You need to maintain a list of these users so your array is already way larger than 8 bits.

Can someone intuit why the 256 limit in WhatsApp?

Post reply on HN