From: Dmitry A. Kazakov on
On Fri, 16 Jul 2010 22:35:14 +0000 (UTC), Warren wrote:

> I'll need
> to test it on other platforms, but hopefully most if not all
> IEEE platforms will support this.

IEEE representations have more than +Inf, -Inf and NaN. There are other
objects: +0, -0, denormalized numbers (see attribute 'Denorm). Some have
dubious semantics:

with Ada.Text_IO; use Ada.Text_IO;
procedure IEEE_Zeros is
Zero : Float := 0.0;
N0 : Float := 0.0 / (-1.0 / Zero);
begin
Put_Line ("-0 =" & Float'Image (N0) & " 0 = " & Float'Image (Zero));
Put_Line ("-0 = 0 " & Boolean'Image (N0 = Zero));
Put_Line ("-0 < 0 " & Boolean'Image (N0 < Zero));
end IEEE_Zeros;

Negative zero is zero but not equal to, etc.

What are you trying to achieve? Because in automation we have the rule
never ever let IEEE cripples slip through. Don't read them, don't write
them, don't compute them.

The solution Simon suggested is basically everything Ada programmer should
know about IEEE 754! (:-))

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
From: Warren on
Simon Wright expounded in news:m2tynytykr.fsf(a)pushface.org:

> Warren <ve3wwg(a)gmail.com> writes:
>
>> To detect NaN then, this seems to work:
>
> See above, where Jean-Pierre said
>
>> If X /= X, then X is a NaN (see http://en.wikipedia.org/wiki/NaN)

Thanks. I later had a head slapping moment on the
weekend where I had figured that out. ;-)

Warren
From: Warren on
Dmitry A. Kazakov expounded in
news:5xj0ja9xywto$.3ncqua6onpoa.dlg(a)40tude.net:

> On Fri, 16 Jul 2010 22:35:14 +0000 (UTC), Warren wrote:
> IEEE representations have more than +Inf, -Inf and NaN. There are
> other objects: +0, -0, denormalized numbers (see attribute 'Denorm).
> Some have dubious semantics:

Ya, I know about those. As indicated in my other reply,
I did eventually figure out that if F /= F, then it is NaN
(for some reason, I didn't see this at first).

> What are you trying to achieve? Because in automation we have the rule
> never ever let IEEE cripples slip through. Don't read them, don't
> write them, don't compute them.

In my Basic interpreter, I'll raise an error if you try to
use these IEEE values in an argument to a function or try to
compute something with an operator (here NOT 'Valid is sufficient).
However, if the expression result is one of these, I do allow
it to be assigned to a [basic] variable.

So then the user needs a (basic) function to test if the
variable V is +/- infinity or NaN. So in basic, ISNAN(X)
returns 1 if NaN, else zero, for example.

In the C version of the interpreter, I relied upon C functions
for these tests. Ada clearly does not need these C functions,
which is bliss for the Ada rewrite.

Thanks for everyone's help.

Warren
From: Randy Brukardt on
"Warren" <ve3wwg(a)gmail.com> wrote in message
news:Xns9DB6AD1651560WarrensBlatherings(a)81.169.183.62...
> Is there any is not-a-number or is-infinity test support in
> Ada05+ (for floats)? Is there any being planned?

We considered it for Ada 2005 (see AI95-0315-1). It was abandoned because of
the large impact on implementations and the weak demand (hardly any user
requests).

John Barnes mentions this in the Ada 2005 Rational:
http://www.adaic.com/standards/05rat/html/Rat-9-3-3.html

It wasn't resurrected for Ada 2012, so there won't be any change here.

BTW, GNAT seems to pass through a lot of IEEE stuff, thus you can write
examples using that. Other Ada compilers (at least as of 2003-4 timeframe)
vary widely in what is exposed (Janus/Ada only supports IEEE denormal
numbers; everything else raises Constraint_Error before it is stored).

Randy.




From: Warren on
Randy Brukardt expounded in news:i22m9q$cd4$1(a)munin.nbi.dk:

> "Warren" <ve3wwg(a)gmail.com> wrote in message
> news:Xns9DB6AD1651560WarrensBlatherings(a)81.169.183.62...
>> Is there any is not-a-number or is-infinity test support in
>> Ada05+ (for floats)? Is there any being planned?
>
> We considered it for Ada 2005 (see AI95-0315-1). It was abandoned
> because of the large impact on implementations and the weak demand
> (hardly any user requests).
>
> John Barnes mentions this in the Ada 2005 Rational:
> http://www.adaic.com/standards/05rat/html/Rat-9-3-3.html
>
> It wasn't resurrected for Ada 2012, so there won't be any change here.
>
> BTW, GNAT seems to pass through a lot of IEEE stuff, thus you can
> write examples using that. Other Ada compilers (at least as of 2003-4
> timeframe) vary widely in what is exposed (Janus/Ada only supports
> IEEE denormal numbers; everything else raises Constraint_Error before
> it is stored).
>
> Randy.

Very interesting. My project is fairly dependant on gnat (at the
moment at least), so things should work ok. I'm not personally
a fan of these special IEEE values, but they crop up in 3rd party
libraries like the GSL etc. or in the reading of binary values from
a file.

Warren