Since 1983, the speed of light is defined to be exactly equal to 299,792,458 meters per second. So, it seems natural to define it as an integer while doing some culculations with Julia, for example, to calculate a Planck’s length. This is how it can be done in Julia REPL:
c = 299_792_458; # the speed of light G = 6.67430e-11; # Gravitational constant h = 6.62607015e-34; # Planck's contant h_bar = h / (2*pi); # reduced Planck's constant planks_length = sqrt(G*h_bar/c^3)
As a result, we immediately get
3.5793584153084007e-32 which at first sight is what the Planck’s length should be.
However, Wikipedia says that the Planck’s length is equal to
You probably already realized that the reason for this is the integer overflow that happens when raising
c to the power of
3. Moreover, it is easy to fix this redefining
c to be a float:
c = 2.99792458e8
After doing so, we get the value of the Planck’s length to be equal to
1.6162550244237053e-35, which coincides with the value stated in Wikipedia.
However, it is not so easy for an everage student of Physics, and it is worring how easy such an error can be done in Julia.
Yes, I do know that this is done for speed and that the possibility of integer overflow is mentioned in the documentation.
However, it is quite worrying that Julia produces such a result even without any warning.
At the very least this means that Julia REPL cannot be used as a scientific calculator by an everage student.
Unfortunately, I do not know if it can be fixed on the design level. But if not, this example should be put at the very beginning of Julia official documentation so that every single user of Julia would be warned about such a possibility: a simple warning about an abstact integer overflow is not enough.