From: gautier_niouzes@hotmail.com
Subject: Q: type matching with IEEE 754 double and Intel endianess
Date: Fri, 7 Dec 2012 00:54:26 -0800 (PST)
Date: 2012-12-07T00:54:26-08:00 [thread overview]
Message-ID: <87c30a6b-cd6b-4f96-b6ea-3358f40c1a54@googlegroups.com> (raw)
Hello,
For a software component (Excel Writer), I have a portable way of getting a binary output for a Long_Float, by using Dmitry's IEEE_754 package.
It is working perfectly fine (see IEEE_Double_Intel_Portable function below).
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 ?
Then a rough type conversion would be sufficient (e.g. IEEE_Double_Intel_Native below). The only advantage of the latter is that it is faster.
Cheers
G.
function IEEE_Double_Intel_Portable(x: Long_Float) return Byte_buffer is
pragma Inline(IEEE_Double_Intel_Portable);
d : Byte_buffer(1..8);
--
use IEEE_754.Long_Floats;
f64: constant Float_64:= To_IEEE(x);
begin
for i in d'Range loop
d(i):= f64(9-i); -- Order is reversed
end loop;
return d;
end IEEE_Double_Intel_Portable;
function IEEE_Double_Intel_Native(x: Long_Float) return Byte_buffer is
pragma Inline(IEEE_Double_Intel_Native);
d : Byte_buffer(1..8);
for d'Address use x'Address;
pragma Import (Ada, d);
begin
return d;
end IEEE_Double_Intel_Native;
next reply other threads:[~2012-12-07 8:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-07 8:54 gautier_niouzes [this message]
2012-12-08 6:31 ` Q: type matching with IEEE 754 double and Intel endianess J-P. Rosen
2012-12-08 20:17 ` gautier_niouzes
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox