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.
Trains in Switzerland are not allowed to have 256 axles
81–90 of 92 posts
Re: Trains in Switzerland are not allowed to have 256 axles
#82To 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…
Re: Trains in Switzerland are not allowed to have 256 axles
#83Earlier 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...
Re: Trains in Switzerland are not allowed to have 256 axles
#84Earlier 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.
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
#85Earlier 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?
Re: Trains in Switzerland are not allowed to have 256 axles
#86The 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…
Re: Trains in Switzerland are not allowed to have 256 axles
#87Earlier 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.
Re: Trains in Switzerland are not allowed to have 256 axles
#88Earlier 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.
Re: Trains in Switzerland are not allowed to have 256 axles
#89Earlier 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...
Re: Trains in Switzerland are not allowed to have 256 axles
#90TIL: Per the article, this 256 limitation also applies to number of users in WhatsApp conversations and the maximum block height of a Minecraft world.
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?