Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

double precision in Ada?

I'm very new to Ada and was trying to see if it offers double precision type. I see that we have float and

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

on my machine gives a value of 6, which is not enough for numerical computations.

Does Ada has double and long double types as in C?

Thanks a lot...

like image 484
yCalleecharan Avatar asked Apr 20 '10 19:04

yCalleecharan


1 Answers

It is a wee bit more complicated than that.

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

In practice, your compiler almost certianly defines Float as a 32-bit IEEE float, and Long_Float as a 64-bit. Note that C pretty much works this way too with its float and double. C doesn't actually define the size of those.

If you absolutely must have a certian precision (eg: you are sharing the data with something external that must use IEEE 64-bit), then you should probably define your own float type with exactly that precision. That would ensure your code is either portable to any platform or compiler you move it to, or that it will produce a compiler error so you can fix the issue.

like image 141
T.E.D. Avatar answered Sep 19 '22 12:09

T.E.D.