# The value of \`one\` when using pi and E

**URL:** <https://discourse.julialang.org/t/the-value-of-one-when-using-pi-and-e/105875>\
**Category:** General Usage\
**Tags:** question\
**Created:** [November 6, 2023, 8:05pm UTC](https://discourse.julialang.org/t/the-value-of-one-when-using-pi-and-e/105875 "2023-11-06T20:05:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![scottrsm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/scottrsm/32/208959_2.png) [@scottrsm](https://discourse.julialang.org/u/scottrsm)\
**Post date:** [November 6, 2023, 8:05pm UTC](https://discourse.julialang.org/t/the-value-of-one-when-using-pi-and-e/105875/1 "2023-11-06T20:05:06Z")

</div>

When using `\pi` or `\euler` with the function `one` the value is the boolean value: `true` rather than 1.0. For other irrational values like sqrt(2) the value is 1.0 as it should be. Why is this?

---

<div class="post-metadata">

**Author:** ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Post date:** [November 6, 2023, 8:11pm UTC](https://discourse.julialang.org/t/the-value-of-one-when-using-pi-and-e/105875/2 "2023-11-06T20:11:48Z")

</div>

> [@scottrsm](#):
>
> For other irrational values like sqrt(2) the value is 1.0

While \sqrt{2} is not rational, `sqrt(2)` is a floating-point number, thus rational.

> [@scottrsm](#):
>
> as it should be

Why?

---

<div class="post-metadata">

**Author:** ![scottrsm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/scottrsm/32/208959_2.png) [@scottrsm](https://discourse.julialang.org/u/scottrsm)\
**Post date:** [November 6, 2023, 8:18pm UTC](https://discourse.julialang.org/t/the-value-of-one-when-using-pi-and-e/105875/3 "2023-11-06T20:18:10Z")

</div>

Yes, I realized after I typed it that sqrt(2) is not irrational in the language. I did an @code\_llvm on the call for pi and it seems it is making a distinction between Floats and irrational numbers. But why is this?

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [November 6, 2023, 8:23pm UTC](https://discourse.julialang.org/t/the-value-of-one-when-using-pi-and-e/105875/4 "2023-11-06T20:23:44Z")

</div>

> [@scottrsm](#):
>
> `\pi` or `\euler` with the function `one` the value is the boolean value: `true` rather than 1.0.

`true` in Julia is numerically equal to 1. It is the most “basic” multiplicative identity the sense that multiplying by any other type will up-promote to the precision of the larger type:

```julia
julia> true * 1 # returns Int
1

julia> true * 1.0 # returns Float64
1.0

julia> true * 1.0f0 # returns Float32
1.0f0

```

I think it is returned as the multiplicative identity for `Irrational` constants because we’re not sure what other type of `1` to return in that case.

Whereas `1.0` is a `Float64` value. This is the multiplicative identity for `Float64` types, but you wouldn’t want to use it for arbitrary types because it will cause type promotion to `Float64`:

```julia
julia> 1.0 * 3 # promotes Int to Float64
3.0

julia> 1.0 * 3.0f0 # promotes Float32 to Float64
3.0

```

---

<div class="post-metadata">

**Author:** ![scottrsm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/scottrsm/32/208959_2.png) [@scottrsm](https://discourse.julialang.org/u/scottrsm)\
**Post date:** [November 6, 2023, 8:33pm UTC](https://discourse.julialang.org/t/the-value-of-one-when-using-pi-and-e/105875/5 "2023-11-06T20:33:44Z")

</div>

Thank you, that makes sense.
