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-20 16:36:40 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!nycmny1-snh1.gtei.net!news.gtei.net!newsfeed.mathworks.com!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!skynet.be!skynet.be!skynet.be!skynet.be!louie!tlk!not-for-mail Sender: lbrenta@lbrenta Newsgroups: comp.lang.ada Subject: Re: float with 24-bit resolution References: <3F3CCB0F.543478AF@adrianhoe.nospam.com.my> <3f40a43e@baen1673807.greenlnk.net> <3F43D1AB.10205@attbi.com> From: Ludovic Brenta Date: 21 Aug 2003 01:36:18 +0200 Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Organization: -= Belgacom Usenet Service =- NNTP-Posting-Host: 80.200.133.180 X-Trace: 1061422596 reader0.news.skynet.be 305 80.200.133.180:44873 X-Complaints-To: usenet-abuse@skynet.be Xref: archiver1.google.com comp.lang.ada:41753 Date: 2003-08-21T01:36:18+02:00 List-Id: "Robert I. Eachus" writes: > Martin Dowie wrote: > > > Don't forget that 'fixed-point' is itself sub-divided into 2 categories: > > 'ordinary' > > and 'decimal', though I've never found a need for the 'decimal' flavour > > myself :-) > > It is more of a convenience in declaring decimal fixed point types > than any inherent difference once the types are created. > > type Dollars is digits 9 delta 0.01; > > on most machines should produce exactly the same type as: > > type Dollars is delta 0.01 range -2.0**31/100..2.0**31/100; > for Dollars'Small use 0.01; > > But if you are doing financial work it is much clearer. (It says I > want a type that corresponds to Cobol +9999999.99. More important than being clearer, decimal types avoid some rounding errors that only occur in binary representations. Some decimal numbers do not have a finite representation in base 2. For example, the number 0.42 (in base 10) becomes 0.01101011100001010001... in base 2. This is one number that would require an infinite number of bits to represent exactly, so any calculations made with it would involve some rounding and loss of precision. The financial sector is one particular industry where calculations must be absolutely exact to some number of decimal, not binary, places. It is common, there, to use packed-decimal representations where 4 bits correspond to exactly 1 decimal place. In packed decimal, 0.42 would become 0.01000010, requiring a finite number of bits. -- Ludovic Brenta.