Ada Programming/Types/digits: Difference between revisions
< Ada Programming | Types
[checked revision] | [checked revision] |
Content deleted Content added
no deprecated templates |
m Reverted edits by 37.154.171.54 (talk) to last version by PokestarFan Tag: Rollback |
||
(5 intermediate revisions by 4 users not shown) | |||
Line 22: | Line 22: | ||
== See also == |
== See also == |
||
=== Wikibook === |
=== Wikibook === |
||
Line 36: | Line 36: | ||
* {{Ada/RM3|3|5|7|Floating Point Types}} |
* {{Ada/RM3|3|5|7|Floating Point Types}} |
||
<noinclude> |
<noinclude> |
||
[[ |
[[{{BOOKCATEGORY|Ada Programming}}|Digits]] |
||
⚫ | |||
</noinclude> |
</noinclude> |
||
⚫ |
Latest revision as of 00:27, 19 September 2019
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:
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[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