From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on ip-172-31-74-118.ec2.internal X-Spam-Level: * X-Spam-Status: No, score=1.0 required=3.0 tests=BAYES_20,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: =?UTF-8?Q?Bj=c3=b6rn_Lundin?= Newsgroups: comp.lang.ada Subject: Re: Fixed vs float and precision and conversions Date: Wed, 8 Jul 2020 23:24:55 +0200 Organization: A noiseless patient Spider Message-ID: References: <756885db-118a-4d76-b90d-e547a3cabf28o@googlegroups.com> <518ff68b-1017-4775-8248-c40048b4fe67o@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Wed, 8 Jul 2020 21:24:55 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="bbc4443e166da1163e3df9d7300a854c"; logging-data="4599"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19SRmdzCyyC0yo/8pVbz2M/" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 Cancel-Lock: sha1:RIb6IVClZF7CmbCZ47fSiTgdE28= In-Reply-To: Content-Language: en-US Xref: reader01.eternal-september.org comp.lang.ada:59406 List-Id: Den 2020-07-08 kl. 22:34, skrev Niklas Holsti: > > No, see below. You are confusing decimal (base-10) reals with binary > (base-2) floats. Yes. >> It is at least not certain that the number expressed in fixed_type is >> one of them in the array below. >> And that is my real problem - I think. > > > That is certainly true -- if you don't know anything about the Float > number, then you won't know much about the result of Fixed_Type'Round on > that Float number. If you want to be sure that the result is one of the > numbers in your table, you have to check. > yes - I realize that > > But the values in the Global_Odds table are all given with two decimals, > not three, so why not define Fixed_Type with delta 0.01, which avoids > this possible Float precision problem, as well as being more apt? Because I wanted to express 6.5% -> 0.065 in fixed_type as well. I think I mentioned that in a post. Fixed_type is used generally here (in this system) instead of float, not only for that array. This may have been a bad design choise though. -- Björn