411 REFERENCE · Wikibooks
Ada Programming/Types/digits
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
Types digits
__TOC__
Description
Floating point
To define a floating point type, you only have to say how many digits are needed, i.e. you define the relative precision:
digits Num_Digits
If you like, you can declare the minimum range needed as well:
digits Num_Digits range Low .. High
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
Wikibook
Ada Programming
Ada Programming/Types
Ada Programming/Types/range
Ada Programming/Types/delta
Ada Programming/Types/mod
Ada Programming/Keywords/digits
Ada Reference Manual
3 5 7 Floating Point Types
Digits
es:Programación en Ada/Tipos/Coma flotante