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-Thread: 103376,548c38bb2d3e1bb6 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!feeder.news-service.com!newsfeed.straub-nv.de!nuzba.szn.dk!news.jacob-sparre.dk!pnx.dk!not-for-mail From: Jacob Sparre Andersen Newsgroups: comp.lang.ada Subject: Re: understanding floating point types Date: Tue, 24 Aug 2010 16:05:46 +0200 Organization: Jacob Sparre Andersen Message-ID: <87wrrgjebp.fsf@hugsarin.sparre-andersen.dk> References: <74406fc1-f64b-4a3e-9dd6-301f1ed467ab@w30g2000yqw.googlegroups.com> <7b0ca24f-4a5e-43a9-9f71-e4adffb98694@q1g2000yqg.googlegroups.com> <37d8fbc1-fdaf-4ca9-9393-6163f2e3fa2e@s9g2000yqd.googlegroups.com> <2d2a622b-6c4a-45b7-9e3c-a565d5dbc9e3@p3g2000yqp.googlegroups.com> <5c162267-72b0-49a0-bed2-620e880612df@k10g2000yqa.googlegroups.com> <22d531ff-b6f1-44dc-8b5e-7d93f713b418@z28g2000yqh.googlegroups.com> <59c78dcf-160f-458c-ae60-1e5562a9bff3@5g2000yqz.googlegroups.com> NNTP-Posting-Host: 95.209.236.252.bredband.3.dk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: munin.nbi.dk 1282658746 12851 95.209.236.252 (24 Aug 2010 14:05:46 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Tue, 24 Aug 2010 14:05:46 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:WfH4KN1221O0oHiuHM+Jps3rWSQ= Xref: g2news1.google.com comp.lang.ada:13701 Date: 2010-08-24T16:05:46+02:00 List-Id: Ada novice writes: > I have just read the following from an Ada book by Fintan Culwin: > ---- > type VeryAccurate is digits 16 > type NotAccurate is digits 2 > > Values of the type VeryAccurate would have limited range with a high > degree of precision. Values of the type NotAccurate would have a much > greater range with only two digits of precision. > ---- > > My understanding is that using "B = 3.32*D + 1", a type with digits 16 > (D = 16) will have a higher B value and hence a higher exponent range > -4*B to 4*B than a type with digits 2. Will a higher exponent range > not give a higher range? > > What am I understanding wrong here? You're using a random equation. Fintan Culwin is probably assuming that you allocate a fixed number of bits to represent a floating point number. The fewer of those bits, which are allocated to precision, the more can be allocated to the exponent (and thus the range). But in practice your compiler may choose exactly the same representation for both of the types in the example above. Greetings, Jacob -- "The same equations have the same solutions."