Forum > General
[Solved] Defining floating point constants
MathMan:
Hello all,
In some cases it neccessary/preferred to define floating point constants in a way that is precise/unambiguous. In C one can define a floating point constant in hexadecimal notation like
--- 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_single = 0x1.234567p1; const_double = 0x1.23456789abcdefp-1;
Is something similar possible in FPC? I seem to only find decimal notation referenced for floating point.
Cheers,
MathMan
MathMan:
Nothing?
Not even a secured "No, can't be done."?
marcov:
Not documented at least. See e.g. numlib where constants are defined an array of bytes, and then typecast into float.
MathMan:
--- Quote from: marcov on November 23, 2024, 06:11:05 pm ---Not documented at least. See e.g. numlib where constants are defined an array of bytes, and then typecast into float.
--- End quote ---
Thanks marcov - was afraid it is like that and that I have to use the solution you mentioned.
Warfley:
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)
Navigation
[0] Message Index
[#] Next page