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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,9ba6f8b7673f12aa,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-03-24 17:47:52 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!supernews.com!207.217.77.43.MISMATCH!newsfeed1.earthlink.net!newsfeed.earthlink.net!newsmaster1.prod.itd.earthlink.net!newsread2.prod.itd.earthlink.net.POSTED!870a9d88!not-for-mail From: "Eric G. Miller" Subject: Portable binary number types... Newsgroups: comp.lang.ada Message-ID: User-Agent: Pan/0.11.2 (Unix) Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Comment-To: ALL Date: Mon, 25 Mar 2002 01:47:51 GMT NNTP-Posting-Host: 216.119.29.231 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.prod.itd.earthlink.net 1017020871 216.119.29.231 (Sun, 24 Mar 2002 17:47:51 PST) NNTP-Posting-Date: Sun, 24 Mar 2002 17:47:51 PST Organization: EarthLink Inc. -- http://www.EarthLink.net X-Received-Date: Sun, 24 Mar 2002 17:47:52 PST (newsmaster1.prod.itd.earthlink.net) Xref: archiver1.google.com comp.lang.ada:21629 Date: 2002-03-25T01:47:51+00:00 List-Id: I have a datafile format that specifies 2 & 4 byte integers and 4 & 8 byte floating point types. I want to make sure the data types I use in the program, can reliably be read/written to files. It's not crucial that the runtime data types have the same byte count (provided they have the same range). So, I wrote something like: package My_Types is -- 16#8000 is NULL type My_Short is range -32_767 .. 32_767; for My_Short'Size use 16; for My_Short'Alignment use 2; -- 16#80000000 is NULL type My_Long is range -2_147_483_647 .. 2_147_483_647; for My_Long'Size use 32; for My_Long'Alignment use 4; -- Any IEEE NaN is NULL type My_Float is digits 6; for My_Float'Size use 32; for My_Float'Alignment use 4; -- Any IEEE NaN is NULL type My_Double is digits 15; for My_Double'Size use 64; for My_Double'Alignment use 8; end My_Types; Endianness is handled via a character flag, so Read/Write will involve byte swapping (if needed). I've got that covered. I'm less sure about the floating point types. What's really wanted is IEEE conformance. All four have a NULL state, that I'll need to be able to check. I figured I could use a pair of functions to test/set NULL via the Unchecked_Conversion 'Valid and a NULL constant for the Set_Null(). In the general case, is it likely the compiler will see these types as simple redefinitions of native types (if that's the case) and not create a performance penalty for using them? Or is there a better way to handle the requirement?