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_40,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: Thu, 9 Jul 2020 09:23:30 +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: Thu, 9 Jul 2020 07:23:31 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="46e338f25ba6a44fb035b84aa7401a89"; logging-data="12161"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18+5vevkaRqPerZD3CIe+lZ" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 Cancel-Lock: sha1:4C6Rir/d6wu1oxfpR8HJzpWbtyA= In-Reply-To: Content-Language: sv Xref: reader01.eternal-september.org comp.lang.ada:59411 List-Id: Den 2020-07-09 kl. 08:20, skrev Dmitry A. Kazakov: > On 08/07/2020 21:41, Björn Lundin wrote: > >> As I replied to Niklas: >> It is at least not certain that the number expressed in fixed_type is >> one of them in the array below. > > The array has varying step 0.01 to 10.0, your test has step 0.001. What > do you expect? Of course it must fail at a very high rate from 9/1 to > 999/1, practically always. > welll, in practice not always. It only fails when - like my example - Fixed_Type(float(5.10)) becomes 5.099 and its been running with that construct since 2014, and I only noticed now. So - not always, actually very seldom. I did expect floating comparison error to go away using fixed type, but I forgot about 'garbage in -> garbage out' I don't have that kind of rounding errors once the values are converted to fixed_type but I did not realize that I had them in the conversion. -- Björn