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,7a2d45f282a1da1c X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-08-15 05:24:25 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!wn14feed!wn13feed!wn11feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi_feed4!attbi.com!sccrnsc02.POSTED!not-for-mail From: "Jeffrey Creem" Newsgroups: comp.lang.ada References: <3F3CCB0F.543478AF@adrianhoe.nospam.com.my> Subject: Re: float with 24-bit resolution X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Message-ID: NNTP-Posting-Host: 66.31.5.146 X-Complaints-To: abuse@comcast.net X-Trace: sccrnsc02 1060950264 66.31.5.146 (Fri, 15 Aug 2003 12:24:24 GMT) NNTP-Posting-Date: Fri, 15 Aug 2003 12:24:24 GMT Organization: Comcast Online Date: Fri, 15 Aug 2003 12:24:24 GMT Xref: archiver1.google.com comp.lang.ada:41500 Date: 2003-08-15T12:24:24+00:00 List-Id: wrote in message news:3F3CCB0F.543478AF@adrianhoe.nospam.com.my... > Hi, > > I looked through the LRM and searched CLA but I could not find any > solution. Perhaps I've overlook somewhere. > > I need a float with 24-bit resolution. My data needs to be encoded into > 24 bits at a scaling of 720 degrees / 2^24 bits with the most > significant bit being the sign bit. This results in a value that ranges > from +359.9999571 degrees (0x7FFFFF) to -360.0000000 degrees (0x800000) > at increments of approximately 4.291534424e-5 degrees per bit. This does not sound anything like a float at all. It sounds much more like a typical implementation of a fixed point type. Something along the lines of package My_Pack is The_Delta : constant := 4.291534424e-5; type Probably_Gonna_Work_But_Language_Lawyers_Will_Complain_Type is delta The_Delta range - 360.0 .. 359.9999571; for Probably_Gonna_Work_But_Language_Lawyers_Will_Complain_Type'Small use The_Delta; for Probably_Gonna_Work_But_Language_Lawyers_Will_Complain_Type'Size use 24; end My_Pack; There are all sorts of things you can get bitten by here...especially with the 24 bit requirement but when looking for a specific representation the details can be tricky. What are you really trying to achieve at a higher level (e.g. talking to some hardware, sending some message to a device, etc?)