comp.lang.ada
 help / color / mirror / Atom feed
From: gautier_niouzes@hotmail.com
Subject: Re: Q: type matching with IEEE 754 double and Intel endianess
Date: Sat, 8 Dec 2012 12:17:15 -0800 (PST)
Date: 2012-12-08T12:17:15-08:00	[thread overview]
Message-ID: <4530e142-cd98-49e2-9aa3-fea7fbb84b26@googlegroups.com> (raw)
In-Reply-To: <k9ums0$6hs$1@dont-email.me>

Le samedi 8 décembre 2012 07:31:27 UTC+1, J-P. Rosen a écrit :
> Le 07/12/2012 09:54, gautier_niouzes@hotmail.com a écrit :
> 
> > Now, assume the program is running on a machine where Long_Float is actually IEEE_754, and endianess is the Intel one.
> 
> > Is there a "solid" way to prove with some check that it is the case ?
> 
> Uncheck_Convert it to an array of bits, and compare against the expected
> 
> pattern. Unchecked_Conversion is precisely for that: getting at the
> 
> underlying representation

Thanks. Now the question becomes (hence the "solid"): how to eliminate false postives and false negatives ?

Say my test looks like:
x: constant Long_Float:= 1234.0e56;
Can_use_native: constant Boolean:=
  IEEE_Double_Intel_Portable(x) = IEEE_Double_Intel_Native(x);

For eliminating false negatives it is easy since I'm developing on Intel x86 or x64 machines (there are probably borderline cases with more than one binary representation for one decimal one, but it simply is a question of trying another value for the constant x).

Now for false positives, it is probably a question of avoiding some very unlikely cases, e.g. an ieee number with a palindromic byte sequence (where the endianess would be fooled).
Perhaps 2 or 3 constants are better for testing:

Can_use_native: constant Boolean:=
  IEEE_Double_Intel_Portable(x) = IEEE_Double_Intel_Native(x) and
  IEEE_Double_Intel_Portable(y) = IEEE_Double_Intel_Native(y) and
  IEEE_Double_Intel_Portable(z) = IEEE_Double_Intel_Native(z);

Any thought about good choices of constant(s) is welcome :-)
_________________________
Gautier's Ada programming
http://gautiersblog.blogspot.com/search/label/Ada
NB: follow the above link for a valid e-mail address



      reply	other threads:[~2012-12-08 20:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-07  8:54 Q: type matching with IEEE 754 double and Intel endianess gautier_niouzes
2012-12-08  6:31 ` J-P. Rosen
2012-12-08 20:17   ` gautier_niouzes [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox