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



 
hi @all,

i wanted to ask for some concrete help, not to start again long discussions about the inaccuracy of fp-math, IEEE, gnumeric, Excel and Calc.

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.


does anyone have an idea how to calculate the correct! 'power of ten range' in gnumeric similarly effectively?

The number displayed after the 'E' in scientific notation doesn't work, on the one hand it's probably based on string conversion and thus too slow, on the other hand e.g. 10^24 is represented as 9.99999999999999983E+023 instead of 1.00000000000000000E+24 when displayed with 17 decimal places, which of course would give wrong results.

'=int(log10(abs(x)))' fails for e.g. 9,99999999999999858E+001 (100 minus 1 ULP) and plenty other values also increasing with x as the log10 curve flattens with increasing x.
 
best regards,



b.
 
---

i'm still relatively new here, pls. excuse if i am not well adapted to the manners,

aiming for better - more precise - calculations in spreadsheets i'd need a exact marker if a value is below (<) or above (>=) a binary or decimal range border, exactly! differentiating between e.g 0,249999999999999... and 0,25. calculating that with standard tools (log, int and so on) sometimes fails, see samples in attachement including also proof that it is calculateable (col H).

nice would be functions ('bin_range', 'dec_range', 'gnm_bin_range', 'gnm_dec_range'?) calculating that, callable as a function from inside the sheet as well as usable in coding, and taking all the corner cases like zero, NaN, over- and underflow into account. best would be if such already exists in gnumeric and i only overlooked it.

in some respects i should be able to code it by myself, but to get it nicely fitted into the usage, existing functions and 'manners' of gnumeric w/could cause some confusions.

may i kindly ask if an expert tells me whether something like that already exists, and if not would like to hack it together?

(pls. no comments / questions if i really need such precision ... no, 'i' don't need it, but 'math' needs precision in the elementary calculations, e.g. rounding and compares. tolerating inaccuracies here leads to ever spreading waves of fuzziness, in the end you could normalize all numbers to 1 and define 1+1 -> 1, 1-1 -> 1 and all results could be 'calculated' very quickly. if it works to trim the elementary functions to 'exact' all calculations based on it can benefit from that, e.g. correct rounddown and roundup of 0,24999999999999997 to 16 decimal places up to an automatic 'corrective rounding' of 0,300000000000004 as result of 0,1 plus 0,2 without! loss of accuracy. And then it suddenly makes sense! to care about such trifles.)

best regards and thanks in advance ...



b.

Attachment: deco-math_step_00_a_sa_exact_bin_and_dec_ranges _in_gnumeric.ods
Description: application/vnd.oasis.opendocument.spreadsheet



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