Forum > General
[Solved] Defining floating point constants
MathMan:
--- Quote from: Warfley on November 23, 2024, 09:36:07 pm ---You could write down the mantissa as hexadecimal number and then divide by the exponent
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---MyFloat = $AABBCC / (1 shl exp)
--- End quote ---
Beg to differ - shl is only defined for ordinal types. So this breaks as soon as exp >63, doesn't it?
If I have to parse and modify existing constant tables anyway, I think I prefer the variant record approach.
marcov:
While not constant the single/float helpers might make it possible runtime (e.g. once at startup)
Paolo:
"Absolute" can help ?
Declare a integer const with the bit pattern you need, then declare a float const pointing to the previous integer constant.
Not checked.
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Const A = $××××××x B = float absolute A
Again not checked.
marcov:
That's what numlib does with array of bytes.
80-bit integers are somewhat hard anyway :-)
MathMan:
--- Quote from: marcov on November 23, 2024, 10:05:34 pm ---While not constant the single/float helpers might make it possible runtime (e.g. once at startup)
--- End quote ---
Hm - I'll have a look at least, but runtime is definitely not what I can use for all of it.
Background - I currently try to understand how much effort would be involved to port the CORE-Math library https://core-math.gitlabpages.inria.fr/ to Free Pascal. It provides a full set of correctly rounded elementary functions for Single & Double. A lot of mathematical grunt work has gone into that and a full port, including testing environment, would unfortunately require conversion of several millions of FP constants. Even if only the actual function implementation is addressed there are still some thousand involved.
Of course I would also like to know if this is in any way wanted for FPC RTL - and later on I'd need guidance how to do the RTL integration correct.
But at the moment I'm still investigating for an effort estimation.
Navigation
[0] Message Index
[#] Next page
[*] Previous page