Description[edit | edit source]
To define a floating point type, you only have to say how many digits are needed, i.e. you define the relative precision:
If you like, you can declare the minimum range needed as well:
This facility is a great benefit of Ada over (most) other programming languages. In other languages, you just choose between "float" and "long float", and what most people do is:
- choose float if they don't care about accuracy
- otherwise, choose long float, because it is the best you can get
In either case, you don't know what accuracy you get.
In Ada, you specify the accuracy you need, and the compiler will choose an appropriate floating point type with at least the accuracy you asked for. This way, your requirement is guaranteed. Moreover, if the computer has more than two floating point types available, the compiler can make use of all of them.
See also[edit | edit source]
Wikibook[edit | edit source]
- Ada Programming
- Ada Programming/Types
- Ada Programming/Types/range
- Ada Programming/Types/delta
- Ada Programming/Types/mod
- Ada Programming/Keywords/digits