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 20:42:24 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!news-out1.nntp.be!propagator2-sterling!news-in-sterling.nuthinbutnews.com!cyclone1.gnilink.net!wn14feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi.com!sccrnsc01.POSTED!not-for-mail Message-ID: <3F3DA81B.2070701@attbi.com> From: "Robert I. Eachus" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20021120 Netscape/7.01 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: float with 24-bit resolution References: <3F3CCB0F.543478AF@adrianhoe.nospam.com.my> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 66.31.71.243 X-Complaints-To: abuse@comcast.net X-Trace: sccrnsc01 1061005343 66.31.71.243 (Sat, 16 Aug 2003 03:42:23 GMT) NNTP-Posting-Date: Sat, 16 Aug 2003 03:42:23 GMT Organization: Comcast Online Date: Sat, 16 Aug 2003 03:42:23 GMT Xref: archiver1.google.com comp.lang.ada:41552 Date: 2003-08-16T03:42:23+00:00 List-Id: Jeffrey Creem wrote: > 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; Okay, I'll complain. ;-) You can declare the type as type Probably_Gonna_Work_But_Language_Lawyers_Will_Complain_Type is delta The_Delta range - 360.0 .. 360.0; but if you don't want to, you are much more likely to get exactly what you want, and have the users understand it as well, if you say: The_Delta : constant := 720.0/2**24; type Gonna_Work_And_Language_Lawyers_Will_Not_Complain_Type is delta The_Delta range - 360.0 .. 360.0 - The_Delta; for Gonna_Work_And_Language_Lawyers_Will_Not_Complain_Type'Size use 24; -- Robert I. Eachus "As far as I'm concerned, war always means failure." -- Jacques Chirac, President of France "As far as France is concerned, you're right." -- Rush Limbaugh