comp.lang.ada
 help / color / mirror / Atom feed
From: Shark8 <onewingedshark@gmail.com>
Subject: Re: Fixed vs float and precision and conversions
Date: Wed, 8 Jul 2020 14:16:04 -0700 (PDT)	[thread overview]
Message-ID: <5ce081d9-baf5-413b-bf30-8ccaad4d703bo@googlegroups.com> (raw)
In-Reply-To: <re522e$mat$1@dont-email.me>

On Wednesday, July 8, 2020 at 12:08:16 PM UTC-6, björn lundin wrote:
> 
> hmm no. valuies in global_odds_table are fixed_type
>    Global_Odds_Table : array(Tics_Type'Range) of Fixed_Type := (

Except you don't *have*, in the things you are getting [from JSON], fixed-point.
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 compare Floatingpoints to the acceptable-values in the table: for simplicity this means using the table-values as floats. [Conceptually they are universal-numbers.]

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 translation (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 that value will be that value from the table which is the closest value to the input-float.

  parent reply	other threads:[~2020-07-08 21:16 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-07 21:10 Fixed vs float and precision and conversions Björn Lundin
2020-07-07 21:30 ` Niklas Holsti
2020-07-08  8:17   ` Björn Lundin
2020-07-07 21:58 ` Shark8
2020-07-08  8:15   ` Björn Lundin
2020-07-08 16:16     ` Shark8
2020-07-08 18:08       ` Björn Lundin
2020-07-08 18:10         ` Björn Lundin
2020-07-08 18:21           ` Niklas Holsti
2020-07-08 19:39             ` Björn Lundin
2020-07-08 20:34               ` Niklas Holsti
2020-07-08 21:24                 ` Björn Lundin
2020-07-09  7:11                   ` Niklas Holsti
2020-07-08 18:36           ` Dmitry A. Kazakov
2020-07-08 19:41             ` Björn Lundin
2020-07-09  6:20               ` Dmitry A. Kazakov
2020-07-09  7:23                 ` Björn Lundin
2020-07-09  7:49                   ` Dmitry A. Kazakov
2020-07-08 21:16         ` Shark8 [this message]
2020-07-08 21:47           ` Björn Lundin
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox