# Abstract and System-Native Types of Integers and Floats: Int, Integer, Float, AbstractFloat

**URL:** <https://discourse.julialang.org/t/abstract-and-system-native-types-of-integers-and-floats-int-integer-float-abstractfloat/88985>\
**Category:** Internals & Design\
**Tags:** question\
**Created:** [October 19, 2022, 11:48pm UTC](https://discourse.julialang.org/t/abstract-and-system-native-types-of-integers-and-floats-int-integer-float-abstractfloat/88985 "2022-10-19T23:48:27Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![uniment](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/uniment/32/24532_2.png) [@uniment](https://discourse.julialang.org/u/uniment)\
**Post date:** [October 19, 2022, 11:48pm UTC](https://discourse.julialang.org/t/abstract-and-system-native-types-of-integers-and-floats-int-integer-float-abstractfloat/88985/1 "2022-10-19T23:48:27Z")

</div>

Two questions:

1. Why is the abstract type for an integer called `Integer`, meanwhile the abstract type for a float is `AbstractFloat`? This seems like an inconsistent naming pattern: either changing `Integer` to `AbstractInt`, or `AbstractFloat` to `FloatingPoint`, would be more consistent.

2. `Int` and `UInt` are aliases for the system’s native integer types such as `Int64` and `UInt64`, but there’s no such thing for `Float` to refer to the system’s native float type such as `Float64`—why not?

Sorry if this has been addressed elsewhere.

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [October 20, 2022, 12:00am UTC](https://discourse.julialang.org/t/abstract-and-system-native-types-of-integers-and-floats-int-integer-float-abstractfloat/88985/2 "2022-10-20T00:00:11Z")

</div>

1. is very simple. 32 and 64 bit computers both have both types of floating point, so it doesn’t really make sense to refer to one of them as the native float type.

---

<div class="post-metadata">

**Author:** ![jd-foster](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jd-foster/32/35824_2.png) [@jd-foster](https://discourse.julialang.org/u/jd-foster)\
**Post date:** [October 20, 2022, 12:03am UTC](https://discourse.julialang.org/t/abstract-and-system-native-types-of-integers-and-floats-int-integer-float-abstractfloat/88985/3 "2022-10-20T00:03:59Z")

</div>

```julia
julia> D3TypeTrees.TypeTree(Real)
Real
├──Integer
│ ├──Bool
│ ├──Unsigned
│ │ ├──UInt16
│ │ ├──UInt128
│ │ ├──UInt8
│ │ ├──UInt32
│ │ └──UInt64
│ └──Signed
│ ├──Int32
│ ├──Int128
│ ├──Int8
│ ├──BigInt
│ ├──Int64
│ └──Int16
├──AbstractFloat
│ ├──Float16
│ ├──Float64
│ ├──Float32
│ └──BigFloat
├──AbstractIrrational
│ └──Irrational
└──Rational

```

1. seems more like an observation than a question. Would you add `Abstract` to the front of everything that’s not a leaf of the tree? I think it’s likely a tradeoff between ‘consistency’ and verbosity.

---

<div class="post-metadata">

**Author:** ![uniment](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/uniment/32/24532_2.png) [@uniment](https://discourse.julialang.org/u/uniment)\
**Post date:** [October 21, 2022, 11:44am UTC](https://discourse.julialang.org/t/abstract-and-system-native-types-of-integers-and-floats-int-integer-float-abstractfloat/88985/4 "2022-10-21T11:44:18Z")

</div>

Wouldn’t the system’s “native” type generally be considered to be the largest size that incurs zero speed penalty, because the math units and data buses are sufficient for it without extra steps?

If you’re on a 64-bit system, do you default to using Float32 or Float64? why?

---

<div class="post-metadata">

**Author:** ![mikmoore](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mikmoore/32/31109_2.png) [@mikmoore](https://discourse.julialang.org/u/mikmoore)\
**Post date:** [October 21, 2022, 8:06pm UTC](https://discourse.julialang.org/t/abstract-and-system-native-types-of-integers-and-floats-int-integer-float-abstractfloat/88985/5 "2022-10-21T20:06:08Z")

</div>

`Float64` “double-precision” floats are supported on virtually all “standard” computers from the last several decades (eg, much longer than 64bit has been a mainstream thing). The bit-width of a system is orthogonal to its floating point faculties. Some systems even support 80bit “extended double precision” floating point arithmetic, although that is rare nowadays.

If the bit-width of your integers is important, then you should specify them explicitly (there’s no sense using `Int32` on any system if the result will be wrong, even if `Int64` would require non-native operations). But when either is sufficient, it seems Julia has defaulted to the system native choice. There’s nothing wrong with manually specifying integer types, if you prefer, it’s just that much of the time the user may not particularly care.

---

<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:** [October 22, 2022, 6:39pm UTC](https://discourse.julialang.org/t/abstract-and-system-native-types-of-integers-and-floats-int-integer-float-abstractfloat/88985/6 "2022-10-22T18:39:43Z")

</div>

> [@uniment](#):
>
> If you’re on a 64-bit system, do you default to using Float32 or Float64?

You don’t really default to either, but while you may default to Int64 on 64-bit, it’s not because it’s faster (it’s not), it because you want to be able to address all memory, and it’s less likely to overflow. I actually believe Int32 (even on 64-bit) would be a better default to just store numbers (assuming it would have overflow checks, which can be made fast).

---

<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:** [October 22, 2022, 7:57pm UTC](https://discourse.julialang.org/t/abstract-and-system-native-types-of-integers-and-floats-int-integer-float-abstractfloat/88985/7 "2022-10-22T19:57:51Z")

</div>

> [@uniment](#):
>
> `Int` and `UInt` are aliases for the system’s native integer types such as `Int64` and `UInt64`, but there’s no such thing for `Float` to refer to the system’s native float type such as `Float64`—why not?

This exact question seems to come up so often that maybe it should be in the FAQ:

- 2/2014: [If (in my system) Int is an alias for Int32, then why there is no Float alias for Float32/64?](https://groups.google.com/d/msg/julia-users/1tDvMbfCUEE/BJCu0-S7OawJ)
- 4/2013: [typealias for Float](https://groups.google.com/d/msg/julia-users/WXTmzMaj4pc/xsigqax_qi0J)
- 7/2014: [Numerical types and machine word size](https://groups.google.com/d/msg/julia-users/YE8P7En0aaU/w___mZ4WS68J)
- 2/2015: [Int and Float](https://groups.google.com/d/msg/julia-users/qZCio9bQ2MA/EGIJMbEfyvYJ)
- 4/2016: [Int and Int64](https://groups.google.com/d/msg/julia-users/qs3lZj7AaY8/NrNF7dBAAwAJ)
- 2/2014: [Julia default numeric types](http://stackoverflow.com/questions/21743844/julia-default-numeric-types)
- 12/2016: [`Float` type like `Int` type](https://discourse.julialang.org/t/float-type-like-int-type/1164)
- 6/2017: [Win32 bit versus Win64 bit Julia](https://discourse.julialang.org/t/win32-bit-versus-win64-bit-julia/4110)

---

<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:** [October 22, 2022, 8:00pm UTC](https://discourse.julialang.org/t/abstract-and-system-native-types-of-integers-and-floats-int-integer-float-abstractfloat/88985/8 "2022-10-22T20:00:54Z")

</div>

> [@uniment](#):
>
> Why is the abstract type for an integer called `Integer`, meanwhile the abstract type for a float is `AbstractFloat`?

See previous discussions:

> <https://github.com/JuliaLang/julia/issues/8142>
>
> We've seen empirical evidence that new users sometimes use abstract numeric type…s like \`FloatingPoint\` or \`Complex\` in lieu of concrete types like \`Float64\` and \`Complex128\`. The result is that users end up with slow code or even wrong code due to operations over variables with types like \`Array{Complex,2}\` or \`Vector{FloatingPoint}\`. (For example: \[this comment\](https://github.com/JuliaLang/julia/issues/4796#issuecomment-28459235) in #4796)
> 
> The unintentional use of abstract numeric types seems especially prevalent with \`FloatingPoint\` or \`Complex\` which share common prefixes with concrete types. Other abstract numeric types like \`Signed\` or \`Real\` do not seem prone to accidental misuse to the same extent.
> 
> Suggestions for new names? I'd propose something like \`FloatingPointAbstract\` or \`AbstractFloatingPoint\` to emphasize the abstract nature of the type. And perhaps something like \`ComplexCartesian\` instead of \`Complex\` to emphasize the canonical (real, imaginary) representation and to distinguish it from polar forms or other more esoteric representations.

> <https://github.com/JuliaLang/julia/pull/12162>
