Edit: I found the right answer thanks to a friend. Winni was not so far off, but missed an important piece:
const
MyMaxSingle = Single(3.402823466E+38);
// or
MyMaxSingle: Single = 3.402823466E+38;
Defining it with the number requires at least to add the Single type so it is not interpreted as Extended.
Now the hex value of this is precisely 7F7FFFF.
Thanks for the answers so far.
@winni
Why do you want to declare a const as bitmask and not just simple as
MyMaxSingle = 3.402823466E+38;
Unfortunately defining it like in your example adds some rounding errors.
And you dont need to create yourself such problems:
MaxSingle is already defined in the unit math.
I wrote in the first post that FPC's MaxSingle isn't exactly the correct maximum for single point floats. See Wikipedia:
https://en.wikipedia.org/wiki/Single-precision_floating-point_format#Single-precision_examples
@Thaddy:
Thanks for your helpful examples.
The cast to a Record Type would be what comes closest to what I want, but unfortunately this seems not allowed when defining a Const.
About the approaches using functions: Unfortunately I am searching for a way to define it as real Const. Call it silly, but I am at this point curious how this can be done in FPC.
Unfortunately the Compiler does not allow me to define something like:
const
MaxSingle: Single = Int32($7f7fffff).AsBitMaskSingle;
Apparently it does not allow a function call in the initialization of Consts and Vars.
Sure I could just always call a function to output the value to me at the points I need it. But I am really curious how it can be done properly as a real constant value the compiler can then just insert at compile time.