
Trains in Switzerland are not allowed to have 256 axles - edward
https://twitter.com/standupmaths/status/1185544321933758467
======
jt2190
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 just passed. Unfortunately, they keep track of the number of
> wheels using an 8-digit binary number, and when that number reaches 11111111
> it rolls over to 00000000. Any trains which bring the count back to exactly
> zero move around undetected, as phantom trains.

From: "Humble Pi: A comedy of maths errors" by Matt Parker
([https://mathsgear.co.uk/collections/books/products/humble-
pi...](https://mathsgear.co.uk/collections/books/products/humble-pi-a-comedy-
of-maths-errors)), page 191.

edit: Added quote attribution.

~~~
balabaster
So if you want to move around Switzerland undetected, commission a train with
256 axles and bam! You're invisible :P

~~~
scarejunba
Haha one can imagine this will be rapidly bred out of the species since it's
such a significant maladaptation. Like dressing in Vantablack and running on a
rural expressway.

~~~
kijin
To catch intruders dressed in Vantablack, you'll need one of those devices
they use to find exoplanets.

~~~
H8crilA
Or, you know, infrared cameras :)

~~~
TeMPOraL
Or just _more light_ , and focus on shooting the dark spots.

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

~~~
TeMPOraL
_What if we tried more power?_

[https://what-if.xkcd.com/13/](https://what-if.xkcd.com/13/)

------
parsimo2010
In similar news, popular athletic app Strava has announced that they will be
dropping Bluetooth support because of an issue with their code.
[https://support.strava.com/hc/en-
us/articles/360032979131-Re...](https://support.strava.com/hc/en-
us/articles/360032979131-Removing-Direct-Sensor-Pairing-from-the-Strava-
Mobile-App)

Strava aren't fixing the bugs, just dropping the feature altogether. They even
admit that other athletic apps implement Bluetooth without bugs, so it's not a
platform limitation.

So sometimes people decide that an easy fix is a better choice than a
"correct" fix, which would be either adding bits to the train axle counter, or
implementing a way that didn't care how many axles there were- such as having
a head and tail indicator for a train, and not counting the axles in between.

~~~
lonelappde
They obviously have a head and tail indicator already, so they don't merge all
the trains together. The issue is that they overload the axle mod 256 counter
with the train indicator, instead of using a separate byte.

------
fsh
This section is not present in the 2015 or 2016 edition of the rulebook:
[https://www.bav.admin.ch/bav/de/home/rechtliches/rechtsgrund...](https://www.bav.admin.ch/bav/de/home/rechtliches/rechtsgrundlagen-
vorschriften/fdv-2016.html) Seems like overflow detection (or more bits) were
added to the counters at some point.

~~~
kposehn
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.

~~~
SkyPuncher
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.

~~~
dTal
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.

~~~
dwild
Considering that a train can require 2 km to break, I'm sure they keep enough
space between trains that there's plenty of space for both 258 or 2 axles
trains. Knowing a train is there seems much more important than its lengths
(up until they decide that 2 axles trains can be much closer to another
trains).

------
city41
You can carry a maximum of 255 rupees in the original Legend of Zelda, and
back in the day magazines commented on the "oddly specific" number.

~~~
Bayart
That reminds me back when WoW was still 32 bits and people discovered the gold
cap was 2 147 483 647 copper coins.

~~~
reificator
So your gold value was signed? Does WoW allow for debt by tracking negative
values, or was it just an oversight?

~~~
xxs
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.

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

~~~
xxs
> 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.

------
davidkuhta
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.

~~~
soared
Also reminds me of the maximum amount of coins you can have in runescape:
2.147B. They even created silver coins worth 1000 normal coins as a workaround
for people who get to a “max cash stack”.

(Max value in java, even though the game is non longer written in Java)

~~~
stickfigure
The language is irrelevant; this is the maximum value of a 32-bit signed
integer. Specifically, 2,147,483,647.

Java (and other languages) have other ways of representing numbers which allow
larger values, but once you've encoded values into wire protocols and
persistent data structures, they tend to be hard to change.

------
vilhelm_s
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.

~~~
majewsky
You cannot "accidentally" ignore a red light. Driving over one will trigger an
emergency stop unless you specifically disable this mechanism.

------
lordnacho
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 rules very
meticulously.

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

~~~
wincy
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 specific gesture, point and call
out that I’m taking my pill. I haven’t accidentally taken a second one since
because it makes taking my pills so much more memorable.

[https://en.m.wikipedia.org/wiki/Pointing_and_calling](https://en.m.wikipedia.org/wiki/Pointing_and_calling)

~~~
Razengan
Ah yes, there was a popular discussion about it on HN:

Why Japan’s Rail Workers Point at Things - 959 points:
[https://news.ycombinator.com/item?id=14011793](https://news.ycombinator.com/item?id=14011793)

~~~
wincy
Thats the one. Thanks!

------
jefftk
If the law prohibits 256 axles, it should really prohibit any multiple of 256.
A 512-axle train would similarly be erroneously detected as having zero axles.

~~~
Freak_NL
That would be a freight train consisting of 128 units. Not likely in Europe,
where the average freight train has 25 to 30 wagons, and the longest freight
train seems to measure 835m, which will put you in the neighbourhood of 40
units. I'm not even sure that one would fit on the Swiss network; it runs or
ran between Hamburg and Denmark, a route which features not quite as many
elevation differences and tunnels.

Considering this, the chances of even hitting the lower 256 axle mark are
probably negligibly remote as well.

~~~
jefftk
[https://en.wikipedia.org/wiki/Longest_trains](https://en.wikipedia.org/wiki/Longest_trains)
gives 180 cars for the US, and longer for Australia, Brazil, and others. Cars
can also have more than four axles; at the extreme you have
[https://en.wikipedia.org/wiki/Schnabel_car](https://en.wikipedia.org/wiki/Schnabel_car)

But yes, this is probably not an issue in Europe.

------
Aloha
This seems like a perfectly reasonably limitation in the context of european
railroading (shorter trains, more frequency), when you consider that many
European freight cars are 2 axle

~~~
jonp888
Yes, generally freight trains are not allowed to be longer than 740m, because
there would be few sidings or loops long enough to put them in. So in practice
the axle limit is unlikely to be the actual limiting factor.

------
dmit
Previously:
[https://news.ycombinator.com/item?id=12071240](https://news.ycombinator.com/item?id=12071240)

------
esotericn
Shouldn't they also not have anywhere around 256, because if a 258 axle train
has a couple of missed detections it'll still look like 0?

~~~
SilasX
From the previous thread, some countries specific a little below 256 for a
margin of safety:

[https://news.ycombinator.com/item?id=12071686](https://news.ycombinator.com/item?id=12071686)

------
thih9
Looks like this leaves the issue of 256 multiples unresolved.

In theory we could still have a 512 axle ghost train.

------
Grue3
But did you know an Oyster card in London can't have more than 16 fare zones?
This is the reason why some stations on Overground don't accept Oyster cards.

------
viburnum
There was something posted on HN years ago about a mainframe that ran the
French railway pension system. There was something funny about different pay
rates for rates going uphill or downhill, whether the engineer was a military
veteran, etc. Does anyone have a link? I can’t find it now. Thanks.

------
chiph
I'm not sure why they're even counting past 2 (the minimum number of axles to
indicate a railcar is present, at least until someone delivers self-balancing
single-axle railcars) for train detection. Unless it's to estimate track wear,
or for revenue collection?

~~~
makomk
Trains are typically made up of multiple carriages. The axle counters ensure
that all the carriages which enter a section of track leave that section of
track, and that none have detached and been left behind for the next train to
run into.

~~~
war1025
To elaborate on this, I think what is going on is a section has a "counter-
upper" on one side, and a "counter-downer" on the other side.

So while the train is within that segment, the value of the counter is non-
zero. Once they exit, all the axles should get counted again in the opposite
direction and reset the count to zero.

The problem with 256 is that the count would be at zero _while_ you were in
the track segment.

------
adrianmonk
The "fixed with bureaucracy" thing is entertaining, but it's probably a
delusion that the fix is effective.

For one thing, this rule is not intuitive and people aren't likely to remember
it. People have an easier time remembering and following rules whose reasoning
clicks with them. It's not a recipe for success to say, "Oh, there's this one
weird thing that you can't do, and it isn't going to make sense to you why,
but remember not to do it."

I also wonder whether, even if someone in the industry _does_ know the rule
and really wants to follow it, there's an easy method to know whether their
train has 256 axles. Is there a procedure in which axles are counted or an
automated system that does it? If it's a manual procedure, is it time-
consuming and is there pressure to skip that step when you're in a rush?

And, if a fallible human being should make a mistake and run a train with 256
axles, is there any protection against the phantom, undetected train scenario,
or is it a silent failure?

~~~
hkai
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.

~~~
kposehn
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.

~~~
Freak_NL
Yeah, a bit of light browsing yields a 25 to 30 unit average for European
freight trains¹.

[https://www.allianz-pro-
schiene.de/themen/aktuell/740-meter-...](https://www.allianz-pro-
schiene.de/themen/aktuell/740-meter-gueterzug/)

~~~
kposehn
Ah, it’s up from last I checked. Thanks!

------
bob1029
Is 256 the upper limit, or is it just a magic number to be avoided? Is a train
with 258 axles OK?

~~~
jotm
A train with 258 axles counts as a handcar:

[https://en.m.wikipedia.org/wiki/Handcar](https://en.m.wikipedia.org/wiki/Handcar)

:D

~~~
anticensor
Even worse, 260 axles and you are still considered "light" engine (light
engine is a term of art which means locomotive moving on its own power without
hauling anything else).

------
robocat
Which also presumes axle-counters are perfect...

I'm surprised they didn't also ban 255 and 257!

------
spdustin
They should do what the Norwegian Navy does, and put barcodes on the cars.

Why does Norway do it? When their ships pull into home port, they
Scandinavian. ;)

------
a3n
Wah -- wah -- waaahhh.

------
m0zg
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. :-)

~~~
ohazi
But _unsigned_ overflow is defined. Are we expecting a negative number of
axles?

~~~
m0zg
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.

