# The speed of light is an integer. Why should we care?

**URL:** https://discourse.julialang.org/t/the-speed-of-light-is-an-integer-why-should-we-care/40108
**Category:** Internals & Design
**Tags:** integer-overflow
**Created:** [May 25, 2020, 5:16am UTC](https://discourse.julialang.org/t/the-speed-of-light-is-an-integer-why-should-we-care/40108 "2020-05-25T05:16:30Z")
**Posts on this page:** 20
**Page:** 2

<div class="post-metadata">

### Author: ![gevis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gevis/32/11737_2.png) [@gevis](https://discourse.julialang.org/u/gevis)
#### Post date: [May 25, 2020, 3:25pm UTC](https://discourse.julialang.org/t/the-speed-of-light-is-an-integer-why-should-we-care/40108/21 "2020-05-25T15:25:29Z")

</div>

> [@tamasgal](#):
>
> I think the problem starts at the physics students…
> 
> …if a student calculates 3.5793584153084007e-32 as Planck’s length and doesn’t notice that something is horribly wrong, [it is] worrying.

If a professor explains something to students and they do not understand, blame the students.

If the same professor explains the same thing on TV and people don’t understand, blame the professor.

We are now closer to the second pattern. 🙂

---

<div class="post-metadata">

### Author: ![tamasgal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamasgal/32/27946_2.png) [@tamasgal](https://discourse.julialang.org/u/tamasgal)
#### Post date: [May 25, 2020, 3:28pm UTC](https://discourse.julialang.org/t/the-speed-of-light-is-an-integer-why-should-we-care/40108/22 "2020-05-25T15:28:44Z")

</div>

You quoted me wrongly.

I said: “the problem starts at the physics students **not being taught** ”

---

<div class="post-metadata">

### Author: ![tamasgal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamasgal/32/27946_2.png) [@tamasgal](https://discourse.julialang.org/u/tamasgal)
#### Post date: [May 25, 2020, 3:30pm UTC](https://discourse.julialang.org/t/the-speed-of-light-is-an-integer-why-should-we-care/40108/23 "2020-05-25T15:30:49Z")

</div>

I think the division behaviour in Python 2 vs 3 is a nice analogy 😉

---

<div class="post-metadata">

### Author: ![ggggggggg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ggggggggg/32/265_2.png) [@ggggggggg](https://discourse.julialang.org/u/ggggggggg)
#### Post date: [May 25, 2020, 3:30pm UTC](https://discourse.julialang.org/t/the-speed-of-light-is-an-integer-why-should-we-care/40108/24 "2020-05-25T15:30:59Z")

</div>

> [@tamasgal](#):
>
> Edit. btw. it’s rather the `meter` which has been defined to be the path traveled by (monochromatic) light in vaccuum in 1/299 792 458 of a second, not the other way around. 🙈

This changed last year

> Since 2019, the magnitudes of all SI units have been defined by declaring exact numerical values for seven _defining constants_ when expressed in terms of their SI units.

> **[International System of Units](https://en.m.wikipedia.org/wiki/International_System_of_Units)**
>
> The International System of Units, internationally known by the abbreviation SI (from French Système International), is the modern form of the metric system and the world's most widely used system of measurement. Established and maintained by the General Conference on Weights and Measures, it is the only system of measurement with an official status in nearly every country in the world, employed in science, technology, industry, and everyday commerce.
> The SI comprises a coherent system of u...

---

<div class="post-metadata">

### Author: ![tamasgal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamasgal/32/27946_2.png) [@tamasgal](https://discourse.julialang.org/u/tamasgal)
#### Post date: [May 25, 2020, 3:40pm UTC](https://discourse.julialang.org/t/the-speed-of-light-is-an-integer-why-should-we-care/40108/25 "2020-05-25T15:40:48Z")

</div>

OK now I see your point after the edit regarding my last remark 😉 Yeah indeed, it’s closer then…

---

<div class="post-metadata">

### Author: ![simeonschaub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/simeonschaub/32/216566_2.png) [@simeonschaub](https://discourse.julialang.org/u/simeonschaub)
#### Post date: [May 25, 2020, 4:42pm UTC](https://discourse.julialang.org/t/the-speed-of-light-is-an-integer-why-should-we-care/40108/26 "2020-05-25T16:42:59Z")

</div>

> [@Zhong\_Pan](#):
>
> That said, I think having an optional integer overflow warning that can be turned off may not be a bad idea for Julia.

That’s pretty much what [SaferIntegers.jl](https://github.com/JeffreySarnoff/SaferIntegers.jl) is for.

---

<div class="post-metadata">

### Author: ![gevis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gevis/32/11737_2.png) [@gevis](https://discourse.julialang.org/u/gevis)
#### Post date: [May 25, 2020, 4:49pm UTC](https://discourse.julialang.org/t/the-speed-of-light-is-an-integer-why-should-we-care/40108/27 "2020-05-25T16:49:04Z")

</div>

> [@simeonschaub](#):
>
> That’s pretty much what [SaferIntegers.jl](https://github.com/JeffreySarnoff/SaferIntegers.jl) is for.

Yes, but to use this solution, you at least should be warned about its existence in the official documentation. As early as possible. That was the main point of my initial post.

---

<div class="post-metadata">

### Author: ![simeonschaub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/simeonschaub/32/216566_2.png) [@simeonschaub](https://discourse.julialang.org/u/simeonschaub)
#### Post date: [May 25, 2020, 4:51pm UTC](https://discourse.julialang.org/t/the-speed-of-light-is-an-integer-why-should-we-care/40108/28 "2020-05-25T16:51:22Z")

</div>

It is actually mentioned [here](https://docs.julialang.org/en/v1/manual/faq/#faq-integer-arithmetic-1).

---

<div class="post-metadata">

### Author: ![gevis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gevis/32/11737_2.png) [@gevis](https://discourse.julialang.org/u/gevis)
#### Post date: [May 25, 2020, 4:57pm UTC](https://discourse.julialang.org/t/the-speed-of-light-is-an-integer-why-should-we-care/40108/29 "2020-05-25T16:57:22Z")

</div>

It is done in the Frequently Asked Questions section at the very end of the documentation.

If users ask the corresponding question **frequently** , may be it is worth to explain it to them yet in the first sections of the documentation? Preferebly, when introducing the basic arithmetic operations. 🙂

---

<div class="post-metadata">

### Author: ![Zhong\_Pan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zhong_pan/32/19872_2.png) [@Zhong\_Pan](https://discourse.julialang.org/u/Zhong_Pan)
#### Post date: [May 25, 2020, 6:51pm UTC](https://discourse.julialang.org/t/the-speed-of-light-is-an-integer-why-should-we-care/40108/30 "2020-05-25T18:51:22Z")

</div>

Great, thanks! Didn’t know it exists so I learned something today. 🙂

---

<div class="post-metadata">

### Author: ![tk3369](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tk3369/32/2824_2.png) [@tk3369](https://discourse.julialang.org/u/tk3369)
#### Post date: [May 26, 2020, 3:49am UTC](https://discourse.julialang.org/t/the-speed-of-light-is-an-integer-why-should-we-care/40108/31 "2020-05-26T03:49:27Z")

</div>

I was curious about how LLVM handles integer overflow and this blog post came up. It seems quite relevant. Long story short - it’s a sacrifice for performance. Perhaps compiler people can shed more lights.

> **[What Every C Programmer Should Know About Undefined Behavior #1/3](http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html?m=1)**
>
> People occasionally ask why LLVM-compiled code sometimes generates SIGTRAP signals when the optimizer is turned on. After digging in, they find that Clang generated a "ud2" instruction (assuming X86 code) - the same as is generated by...

---

<div class="post-metadata">

### Author: ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)
#### Post date: [May 26, 2020, 6:22am UTC](https://discourse.julialang.org/t/the-speed-of-light-is-an-integer-why-should-we-care/40108/32 "2020-05-26T06:22:37Z")

</div>

@giordano what’s up with the units in that example? shouldn’t it be `m` rather than `J^1/2 s kg^-1/2`?

---

<div class="post-metadata">

### Author: ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)
#### Post date: [May 26, 2020, 6:34am UTC](https://discourse.julialang.org/t/the-speed-of-light-is-an-integer-why-should-we-care/40108/33 "2020-05-26T06:34:01Z")

</div>

They’re equivalent. Unitful.jl doesn’t normally simplify units.

---

<div class="post-metadata">

### Author: ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)
#### Post date: [May 26, 2020, 7:27am UTC](https://discourse.julialang.org/t/the-speed-of-light-is-an-integer-why-should-we-care/40108/34 "2020-05-26T07:27:26Z")

</div>

Yes I know they’re equivalent, should maybe have made that clear - the question was more specifically why the units weren’t simplified. I thought Unitful did that, but clearly I haven’t worked enough with it.

---

<div class="post-metadata">

### Author: ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)
#### Post date: [May 26, 2020, 9:46am UTC](https://discourse.julialang.org/t/the-speed-of-light-is-an-integer-why-should-we-care/40108/35 "2020-05-26T09:46:42Z")

</div>

As Mason said, `Unitful.jl` doesn’t automatically convert to the simplest unit, because it’s not supertrivial and also because who knows what units the user wants? Physicists can use very strange units, for example the Hubble parameter has the dimension of the inverse of a time, but it’s usually expressed as a speed over distance, e.g. km/s/Mpc.

There is the [`upreferred`](https://painterqubits.github.io/Unitful.jl/stable/conversion/#Unitful.upreferred) function which kind of simplifies to the simplest units:

```julia
julia> using PhysicalConstants.CODATA2018, Unitful

julia> upreferred(sqrt(NewtonianConstantOfGravitation * (PlanckConstant / 2pi) / SpeedOfLightInVacuum ^ 3))
1.616255024423705e-35 m

```

---

<div class="post-metadata">

### Author: ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)
#### Post date: [May 26, 2020, 10:00am UTC](https://discourse.julialang.org/t/the-speed-of-light-is-an-integer-why-should-we-care/40108/36 "2020-05-26T10:00:08Z")

</div>

Sweet, thanks for the explanation!

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [May 27, 2020, 11:35am UTC](https://discourse.julialang.org/t/the-speed-of-light-is-an-integer-why-should-we-care/40108/37 "2020-05-27T11:35:09Z")

</div>

> [@gevis](#):
>
> If users ask the corresponding question **frequently** , may be it is worth to explain it to them yet in the first sections of the documentation?

By definition, there are only a limited number of “first sections” in the documentation. You can’t put a lot of things there. Almost all the items in the FAQ are actually frequently asked.

> [@gevis](#):
>
> it will always remain a **niche** programming language

We get this prediction a lot from people who don’t think that reading the docs is worth their time, and/or find that their quick proposals for redesigning the language are not met with wide approval.

FWIW, I am now resigned to the fact that Julia will be a niche language, with the niche defined as _“used by people who actually read the docs”_.

There are worse fates.

---

<div class="post-metadata">

### Author: ![gevis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gevis/32/11737_2.png) [@gevis](https://discourse.julialang.org/u/gevis)
#### Post date: [May 27, 2020, 1:39pm UTC](https://discourse.julialang.org/t/the-speed-of-light-is-an-integer-why-should-we-care/40108/38 "2020-05-27T13:39:53Z")

</div>

> [@Tamas\_Papp](#):
>
> By definition, there are only a limited number of “first sections” in the documentation. You can’t put a lot of things there.

The first sections of the documentation are not overloaded with new information to say the least, so putting there a good example definitely does not hurt.

> [@Tamas\_Papp](#):
>
> people who don’t think that reading the docs is worth

I am using Linux since the time Microsoft ended its suppot of MS DOS 6.22, that is, about 30 years already. Most of this time, the Linux community stated that their operating system is the best ever, and almost every question on how to do something in it was replied by just “read the documentation,” though the documentation at that time was and still is very poor, not complete and mostly out of date. The following suggestion to go and use Windows was also not rare at all. As a result, after about 30 years of development, the market share of “the best operating system ever” is still very tiny as it is shown [here](https://netmarketshare.com/operating-system-market-share.aspx?options=%7B%22filter%22%3A%7B%22%24and%22%3A%5B%7B%22deviceType%22%3A%7B%22%24in%22%3A%5B%22Desktop%2Flaptop%22%5D%7D%7D%5D%7D%2C%22dateLabel%22%3A%22Trend%22%2C%22attributes%22%3A%22share%22%2C%22group%22%3A%22platform%22%2C%22sort%22%3A%7B%22share%22%3A-1%7D%2C%22id%22%3A%22platformsDesktop%22%2C%22dateInterval%22%3A%22Monthly%22%2C%22dateStart%22%3A%222019-05%22%2C%22dateEnd%22%3A%222020-04%22%2C%22segments%22%3A%22-1000%22%7D), and Linus Torvalds still have to answer questions on [Why Linux is not competitive on desktops?](https://www.youtube.com/watch?v=KFKxlYNfT_o)

This errogant tendency has been changed only recently after Linux community was **massively** accused of being toxic.

The same happens here. In my initial post, I pointed out to the improvement that can be made to the documentation and got a lot of replied of the form: “It is already written there. It is already done in the best possible way. If you don’t like it, you are free to go and use any other programming language.” And that’s is just as toxic, arrogant and self-complacent as it was in the case of Linux.

Recently, I spoke with quite a lot of programmers trying to persuade them to try Julia or asking their opinion about it if they already tried it. Each of them gave me a very pricise answer on why he are not going to use Julia in his project. One of these answers, from a programmer currently working in Rust, which is far not the only programming language he ever used, was quite striking for me at the time. He said: “This project is far from being mature and its community is too **self-complacent**. So, I don’t believe that they will do a good product at the end.” Now, I do understand what he meant.

---

<div class="post-metadata">

### Author: ![johnmyleswhite](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnmyleswhite/32/31_2.png) [@johnmyleswhite](https://discourse.julialang.org/u/johnmyleswhite)
#### Post date: [May 27, 2020, 1:52pm UTC](https://discourse.julialang.org/t/the-speed-of-light-is-an-integer-why-should-we-care/40108/39 "2020-05-27T13:52:10Z")

</div>

It seems like this thread has gotten heated enough that it would be better to let everyone cool down a bit.

---

<div class="post-metadata">

### Author: ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)
#### Post date: [May 27, 2020, 2:33pm UTC](https://discourse.julialang.org/t/the-speed-of-light-is-an-integer-why-should-we-care/40108/40 "2020-05-27T14:33:28Z")

</div>

> [@gevis](#):
>
> At the very least this means that Julia REPL cannot be used as a scientific calculator by an everage student.

This discussion is heating up, I think, because the topic is moving.

I quoted the primary problem of the OP (and others in other threads).  
It is about expectations. What do people/users/developers can expect? What should someone expect? Shifted already to: what can someone expect from the Julia community!

The main problem Julia has, is, that it produces many many expectations, very divers expectations, like “it has to be a scientific calculator” (at least the REPL) or like “it must be faster than C++ or Java or Python” (put your own language in).

I see this pattern in many discussions: Julia as a general programming language, Julia as a data exploration language, Julia for scripting, … it must always be better than what has been used before.

As always and for everything, same for Julia, it can not be everybodys darling. Trying to be makes everybody unhappy.

To answer the quote above in a very simple way:

This is true. A powerfull language as Julia is, it should not be used as scientific calculator by an average student! I wouldn’t suggest to an average student to use Python as this. There are scientific calculators out there, use them!

But, if you want to learn something, if you want to be more than average, go and create your own scientific calculator and you may use Julia and the REPL to build up a new package “ScienceCalc”. Or use another language, as you wish. The important point is: If you want to use something, choose the right tool. If you want to create something, don’t be a user, be a creator.

This is, what Julia is for at first: to make new things possible. In a new and more productive way.  
It is not about makeing old things better or faster.

PS: If I am wrong and OP is really only about integer overflow I say: This is so basic, it should not be part of some warning in some first sections of the documentation, because there would be so many other basic things, it would just not be readable for people, who want to learn Julia. In fact, integer overflow is a general problem in programming, it should be read in general programming books, not in specific language documentations. This  
[https://docs.julialang.org/en/v1/manual/integers-and-floating-point-numbers/#Overflow-behavior-1](https://docs.julialang.org/en/v1/manual/integers-and-floating-point-numbers/#Overflow-behavior-1)  
is just perfect and enough.

[Previous page](https://discourse.julialang.org/t/the-speed-of-light-is-an-integer-why-should-we-care/40108.md?page=1)

[Next page](https://discourse.julialang.org/t/the-speed-of-light-is-an-integer-why-should-we-care/40108.md?page=3)
