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.8 required=3.0 tests=BAYES_50,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Received: by 2002:ac8:6f7a:: with SMTP id u26mr60856547qtv.33.1594242964881; Wed, 08 Jul 2020 14:16:04 -0700 (PDT) X-Received: by 2002:aca:c143:: with SMTP id r64mr8708403oif.7.1594242964615; Wed, 08 Jul 2020 14:16:04 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.uzoreto.com!tr2.eu1.usenetexpress.com!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 8 Jul 2020 14:16:04 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: google-groups.googlegroups.com; posting-host=146.5.2.231; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC NNTP-Posting-Host: 146.5.2.231 References: <756885db-118a-4d76-b90d-e547a3cabf28o@googlegroups.com> <518ff68b-1017-4775-8248-c40048b4fe67o@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <5ce081d9-baf5-413b-bf30-8ccaad4d703bo@googlegroups.com> Subject: Re: Fixed vs float and precision and conversions From: Shark8 Injection-Date: Wed, 08 Jul 2020 21:16:04 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader01.eternal-september.org comp.lang.ada:59405 List-Id: On Wednesday, July 8, 2020 at 12:08:16 PM UTC-6, bj=C3=B6rn lundin wrote: >=20 > hmm no. valuies in global_odds_table are fixed_type > Global_Odds_Table : array(Tics_Type'Range) of Fixed_Type :=3D ( Except you don't *have*, in the things you are getting [from JSON], fixed-p= oint. You are getting IEEE-float, as a consequence of JSON's definition. In order to find the proper values for a non-'Round-able you have to compar= e Floatingpoints to the acceptable-values in the table: for simplicity this= means using the table-values as floats. [Conceptually they are universal-n= umbers.] By putting the global-table in the convert function, as an array of floats,= I got rid of the need for Tics_Type, as well as simplifying the translatio= n (if-needed). Take a look at the conversion function you provided, and the one I provided= ; there are two big differences: mine will return a valid Odds value, and t= hat value will be that value from the table which is the closest value to t= he input-float.