Re: How to byte swap an IEEE Float?



"Björn" <ssh9614@xxxxxxxxxxx> writes:

>> See SAL.Network_Order.Gen_Scalar_64 at
>> http://www.toadmail.com/~ada_wizard/ada/sal.html for a convenient way
>> to do this.
>
> Thanks! I will check it out.
>
>> Hmm. Are you saying the original value is _not_ a NaN? If so, then
>> your swap implementation is faulty; try mine.
>
> No the original value _is_ a NaN when read as a float on x86 (the
> subject on this thread was perhaps a bit misleading)

Ok. So you have some code that generates a NaN, sends it over a
network or something, and then some Ada code wants to store it in a
Float value, still as a NaN.

Unchecked_Conversion should support that. I'm not quite clear what
will happen when you try to use the value or even assign the value;
you'll probably get Constraint_Error. You might try 'Valid.

The Ada model of floating point numbers does _not_ include NaN's, nor
infinities.

--
-- Stephe

.