comp.lang.ada
 help / color / mirror / Atom feed
From: "Björn Lundin" <b.f.lundin@gmail.com>
Subject: Re: Fixed vs float and precision and conversions
Date: Wed, 8 Jul 2020 23:47:09 +0200	[thread overview]
Message-ID: <re5esu$bp0$1@dont-email.me> (raw)
In-Reply-To: <5ce081d9-baf5-413b-bf30-8ccaad4d703bo@googlegroups.com>

Den 2020-07-08 kl. 23:16, skrev Shark8:
> 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.]
> 


hmm, it is difficult to condense a case to a simple case that 
demostrates the problem - and then does not over-simplify it, compared 
to showing lots of things that removes clarity - but then seems to be 
needed anyway.


> 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).

Yes, but Tics_Type is needed anyway.
Say I want to green up (put my self were I win no matter outcome of event))

I say runner 1 wins @ 1.85 and risk €10
then later - when runner 1 seems to be winning, odds have dropped to 
1.25 i say runner 1 does NOT win @1.25 risk €16

if it wins I get €10 *(1.85 -1.0) = €8.5
I also loose the lay-bet = - €16 *(1.25 -1.0) = -€4.0
total win = €8.5 - €4.0 = €4.5

if it looses
I get the €16
and loose the €10 => €16 -€10 = €6

Sometimes you want to calculate how much to risk the second bet
and using the array is nice then.
Sometimes I can say I want to greenup on a delta-tics = 20
That makes calculations easy

> 
> 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.


yes but if the odds are outside 1.01 -1000.0 I'd like to throw an exception.
You may be right that your function gets the closer value.
I will re-examine.

Thanks again


-- 
Björn

      reply	other threads:[~2020-07-08 21:47 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
2020-07-08 21:47           ` Björn Lundin [this message]
replies disabled

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