Aw: Re: deco-Math project, step 00_a: exact bin and dec 'ranges' (in gnumeric). follow up.




thank you John,

> I assume you are trying to emulate the C function frexp().

almost, what I really want is to use this function 'in the code' to construct a function 'bin_range' which is available in the code and in sheets. I had found it in the meantime, but reaped compiler errors again ...

> Here is a spreadsheet that does that. It's pretty straightforward:

works, did similar for testing which algorithm could work, your sheet is a little off as 2^53 is not represented as 0,5*2^54 but 1,0*2^53, the mantissa has to be normalized to [1 .. 2[ thus 0,5 is wrong, and once you do further calculations with erroneous log / int results in col. B, C you run into wrong exponent, wrong mantissa, both together seemingly correct result, but wrong in the details ... but it is on the right track ...

regarding '16th digit': in other sciences small deviations may be neglectable, in math big things build on things with small flaws will start as big things with small flaws and evolve to big things with big flaws ... sooner or later ...

regards,



b.
 
Gesendet: Donnerstag, 08. Juli 2021 um 23:47 Uhr
Von: "John Denker via gnumeric-list" <gnumeric-list gnome org>
An: gnumeric-list gnome org
Betreff: Re: deco-Math project, step 00_a: exact bin and dec 'ranges' (in gnumeric). follow up.
On 7/8/21 10:52 AM, b. via gnumeric-list wrote:

> is there anyone reading here who can help me to make the following snippet fit
> into gnumeric? i'm not a programmer, i've put it together and tinkered with it a
> bit, in LO Calc it gives me the exponent of an IEEE 754 'double' value as an
> integer, in gnumeric error messages from the compiler.
> double fVal1 = 0.0;
> ...
> fVal1 = GetDouble();
> ...
> auto pValParts1 = reinterpret_cast < const sal_math_Double * > (&fVal1);
> int nbinExp1 = pValParts1->inf_parts.exponent - 1023;
> the alternatives 'log2(x)' or 'int(log2(x))' produce some - few - errors, just
> below range borders, increasing with the magnitude of x as the log2 curve flattens.


I assume you are trying to emulate the C function frexp().

Here is a spreadsheet that does that. It's pretty straightforward:
https://www.av8n.com/hack/frexp.gnumeric

That includes about 15 test cases.
The acid test is verifying that:
a) The mantissa is in range, and
b) The original input can be reconstructed exactly,
using the computed exponent and mantissa.

I "think" the calculation can be simplified by using C4 instead of E4,
and getting rid of column E ... but I don't have a proof of this.
_______________________________________________
gnumeric-list mailing list
gnumeric-list gnome org
https://mail.gnome.org/mailman/listinfo/gnumeric-list


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]