From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=BAYES_00,FORGED_HOTMAIL_RCVD2, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,506514dbbd4d1672,start X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.180.87.165 with SMTP id az5mr1074286wib.1.1354870466580; Fri, 07 Dec 2012 00:54:26 -0800 (PST) Received: by 10.49.71.6 with SMTP id q6mr954450qeu.10.1354870466128; Fri, 07 Dec 2012 00:54:26 -0800 (PST) Path: i11ni41161wiw.0!nntp.google.com!m3no10207298wim.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 7 Dec 2012 00:54:26 -0800 (PST) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=206.122.158.4; posting-account=gRqrnQkAAAAC_02ynnhqGk1VRQlve6ZG NNTP-Posting-Host: 206.122.158.4 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <87c30a6b-cd6b-4f96-b6ea-3358f40c1a54@googlegroups.com> Subject: Q: type matching with IEEE 754 double and Intel endianess From: gautier_niouzes@hotmail.com Injection-Date: Fri, 07 Dec 2012 08:54:26 +0000 Content-Type: text/plain; charset=ISO-8859-1 Date: 2012-12-07T00:54:26-08:00 List-Id: 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;