# Infinity symbol

**URL:** <https://discourse.julialang.org/t/infinity-symbol/73204>\
**Category:** General Usage\
**Tags:** question\
**Created:** [December 16, 2021, 2:44pm UTC](https://discourse.julialang.org/t/infinity-symbol/73204 "2021-12-16T14:44:44Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![ko56](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ko56/32/2684_2.png) [@ko56](https://discourse.julialang.org/u/ko56)\
**Post date:** [December 16, 2021, 2:44pm UTC](https://discourse.julialang.org/t/infinity-symbol/73204/1 "2021-12-16T14:44:44Z")

</div>

Is there any reason that Julia does not allow Inf to be typed in as \infty?

---

<div class="post-metadata">

**Author:** ![mbaz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbaz/32/17295_2.png) [@mbaz](https://discourse.julialang.org/u/mbaz)\
**Post date:** [December 16, 2021, 2:47pm UTC](https://discourse.julialang.org/t/infinity-symbol/73204/2 "2021-12-16T14:47:45Z")

</div>

It is not pre-defined, but it’s allowed.

```julia
julia> const ∞ = Inf
Inf

julia> 1/∞
0.0

```

---

<div class="post-metadata">

**Author:** ![ko56](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ko56/32/2684_2.png) [@ko56](https://discourse.julialang.org/u/ko56)\
**Post date:** [December 16, 2021, 2:58pm UTC](https://discourse.julialang.org/t/infinity-symbol/73204/3 "2021-12-16T14:58:05Z")

</div>

Ah, thanks, I hadn’t thought of that.  
Any reason not to pre-define it?

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [December 16, 2021, 3:02pm UTC](https://discourse.julialang.org/t/infinity-symbol/73204/4 "2021-12-16T15:02:15Z")

</div>

no need, `Inf` is a Float64, unlike `pi`, if we had a type for infinity, we probably would

---

<div class="post-metadata">

**Author:** ![mtfishman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mtfishman/32/30755_2.png) [@mtfishman](https://discourse.julialang.org/u/mtfishman)\
**Post date:** [December 16, 2021, 3:10pm UTC](https://discourse.julialang.org/t/infinity-symbol/73204/5 "2021-12-16T15:10:52Z")

</div>

More specifically, there are packages like [https://github.com/JuliaMath/Infinities.jl](https://github.com/JuliaMath/Infinities.jl) that define `∞` as an alias for a special type, which then can be used to create infinite ranges, arrays, etc. Defining `∞` as an alias for `Inf` would clash with those approaches, and probably not be the most useful definition. For floating point `Inf`, I would guess that usually it is the result of a calculation (likely a calculation on floating point numbers that went wrong), and not something you generally work with directly.

---

<div class="post-metadata">

**Author:** ![josuagrw](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/josuagrw/32/1015_2.png) [@josuagrw](https://discourse.julialang.org/u/josuagrw)\
**Post date:** [December 16, 2021, 3:49pm UTC](https://discourse.julialang.org/t/infinity-symbol/73204/6 "2021-12-16T15:49:04Z")

</div>

Because `Inf` is not infinity. It’s a symbol that represents this series of bits

```julia
julia> bitstring(Inf)
"0111111111110000000000000000000000000000000000000000000000000000"

```

---

<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:** [December 16, 2021, 6:46pm UTC](https://discourse.julialang.org/t/infinity-symbol/73204/7 "2021-12-16T18:46:56Z")

</div>

> [@mtfishman](#):
>
> For floating point `Inf` , I would guess that usually it is the result of a calculation (likely a calculation on floating point numbers that went wrong), and not something you generally work with directly.

On the contrary, floating-point `Inf` is quite useful as an input to a function when you want a parameter to be infinite, e.g. you can use it with [`quadgk`](https://github.com/JuliaMath/QuadGK.jl) to indicate infinite integration bounds (improper integrals), with [`nlopt`](https://github.com/JuliaOpt/NLopt.jl) to indicate an unbounded optimization parameter, with `norm` to specify the [infinity norm](https://en.wikipedia.org/wiki/Uniform_norm), and in many other contexts.

---

<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:** [December 16, 2021, 6:49pm UTC](https://discourse.julialang.org/t/infinity-symbol/73204/8 "2021-12-16T18:49:36Z")

</div>

> [@ko56](#):
>
> Any reason not to pre-define it?

It was proposed and rejected: [Adding the ∞ symbol as an alternative to Inf by wg030 · Pull Request #38815 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/pull/38815)

---

<div class="post-metadata">

**Author:** ![jzr](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jzr](https://discourse.julialang.org/u/jzr)\
**Post date:** [December 16, 2021, 7:00pm UTC](https://discourse.julialang.org/t/infinity-symbol/73204/9 "2021-12-16T19:00:53Z")

</div>

Why is `Inf` capitalized the way it is?

---

<div class="post-metadata">

**Author:** ![pablosanjose](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pablosanjose/32/7006_2.png) [@pablosanjose](https://discourse.julialang.org/u/pablosanjose)\
**Post date:** [December 16, 2021, 7:07pm UTC](https://discourse.julialang.org/t/infinity-symbol/73204/10 "2021-12-16T19:07:45Z")

</div>

Ha! Good point. Why?

---

<div class="post-metadata">

**Author:** ![mtfishman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mtfishman/32/30755_2.png) [@mtfishman](https://discourse.julialang.org/u/mtfishman)\
**Post date:** [December 16, 2021, 7:19pm UTC](https://discourse.julialang.org/t/infinity-symbol/73204/11 "2021-12-16T19:19:32Z")

</div>

> [@stevengj](#):
>
> > [@mtfishman](#):
> >
> > For floating point `Inf` , I would guess that usually it is the result of a calculation (likely a calculation on floating point numbers that went wrong), and not something you generally work with directly.
> 
> On the contrary, floating-point `Inf` is quite useful as an input to a function when you want a parameter to be infinite, e.g. you can use it with [`quadgk`](https://github.com/JuliaMath/QuadGK.jl) to indicate infinite integration bounds (improper integrals), with [`nlopt`](https://github.com/JuliaOpt/NLopt.jl) to indicate an unbounded optimization parameter, with `norm` to specify the [infinity norm](https://en.wikipedia.org/wiki/Uniform_norm), and in many other contexts.

Interesting, thanks for the examples. I would have thought those types of cases would be better handled by an `Infinities.jl`-like symbolic infinity, in order to have a type check for the infinite case instead of a runtime check, since presumably the cases you mention have different implementations for the infinite case. I’m sure the runtime check is no problem in terms of performance for those cases, maybe just tradeoffs in terms of code organization (using dispatch instead of if-statements).

---

<div class="post-metadata">

**Author:** ![ko56](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ko56/32/2684_2.png) [@ko56](https://discourse.julialang.org/u/ko56)\
**Post date:** [December 16, 2021, 8:43pm UTC](https://discourse.julialang.org/t/infinity-symbol/73204/12 "2021-12-16T20:43:06Z")

</div>

Thanks, I see there is/was a variety of opinions.
