Double precision in Ada?

I am very new to Ada and tried to find out if it offers a double precision type. I see that we have a float and

Put( Integer'Image( Float'digits ) ); 

the value 6 is set on my machine, which is not enough for numerical calculations.

Does Ada have double and long double types, as in C?

Thank you so much...

+7
double ada precision numeric
source share
2 answers

It is a little harder than that.

The only predefined floating point type that compilers should support is Float . Compilers can optionally support Short_Float and Long_Float . You should be able to look in the appendex F of your compiler documentation to find out what it supports.

In practice, your compiler almost certainly defines Float as a 32-bit IEEE float, and Long_Float as 64-bit. Note that C works very much the same with its Float and double . C does not actually determine their size.

If you absolutely must have certian precision (for example: you are sharing data with something external that IEEE 64-bit should use), then you should probably define your own float type with exactly precision. This would ensure that your code is portable to any platform or compiler to which you have moved it, or that it will lead to a compiler error so that you can fix the problem.

+7
source share

You can create any float of any size that you like. For a long time, this would be:

 type My_Long_Float is digits 11; 

Wiki Books is a good reference to such things.

+6
source share

All Articles