# 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:** 1\
**Showing post:** 78

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [September 5, 2020, 11:46pm UTC](https://discourse.julialang.org/t/the-speed-of-light-is-an-integer-why-should-we-care/40108/78 "2020-09-05T23:46:10Z")

</div>

At least this is false (for the REPL with alternative REPL modes):

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

Your exact code can work with first doing:

```julia-auto
julia> using SafeREPL # note, exact installation instructions (since not yet registered) at: https://github.com/rfourquet/SafeREPL.jl

```

i.e. without doing:

```julia-auto
c = 299_792_458.0; 

```

what you otherwise could do, to get a floating point number, arguably better.

> [@oheil](#):
>
> should not be used as scientific calculator by an average student!

I’m not sure about that, I support Julia’s defaults, as it’s faster, while I can see both sides on the topic of the defaults, and thus I agree with you; and because of the danger of getting used to that non-default mode, maybe even it shouldn’t be used/installed by default?

My rule of thumb is that what can be measured, e.g. in meters (per sec), such as the speed of light, should use floating point, and what MUST (can?) be counted, e.g. currency (photons?), should use ~~floats~~ integers. [Those rules are sometimes broken, in banking integer cents or decimal (floating point), for dollars, should be used, while for a hedge fund floats can be appropriate for amounts.]

Since the Avogato constant was also brought up, since its SI redefinition in 2019, it’s exactly 6.02214076×10^23, and as atoms can be counted, its an argument for integers (BigInt then)…, while I guess floats (almost) always used.

> [@\[ANN\] SafeREPL: use BigInt by default at the REPL](https://discourse.julialang.org/t/ann-saferepl-use-bigint-by-default-at-the-repl/41271):
>
> With Julia 1.5 around the corner, I’m happy to present [SafeREPL](https://github.com/rfourquet/SafeREPL.jl), a little experimental package which by default interprets Int and Int128 REPL literals as BigInt, and Float64 literals as BigFloat: julia\> using SafeREPL julia\> factorial(40) 815915283247897734345611269596115894272000000000 julia\> sqrt(2.0) 1.414213562373095048801688724209698078569671875376948073176679737990732478462102 julia\> c = 299\_792\_458; c^3 # the cube of the speed of light can even be computed safely! 26944002417373989…

> **[GitHub - JeffreySarnoff/SaferIntegers.jl: These integer types use checked arithmetic,...](https://github.com/JeffreySarnoff/SaferIntegers.jl)**
>
> These integer types use checked arithmetic, otherwise they are as system types.

---

_[View the full topic](https://discourse.julialang.org/t/the-speed-of-light-is-an-integer-why-should-we-care/40108)._
