I have a created a unit FloatView to help you inspect in detail 32-bit (Single) and 64-bit (Double) IEEE 754 floating-point values (in case "every bit counts; note that when floating-point numbers are output in decimal, some information is inevitably lost).
I would like to contribute this unit, and offer it for further integration into FreePascal.
What would I need to do to release it under the same license as other FreePascal libraries?
Would there be any interest in incorporating it?
Here are the supported operations (for Single; a similar set exists for Double):
function SingleToStrBits ( const x: Single ): String; { returns string with bits for sign, biased exponent, and fraction } function SingleToStrBinary ( const x: Single ): String; { returns string with binary scientific representation of x: NaN, +/-Infinity, +/-B.B___Bd+/-E, where
'B' is a bit, 'd' stands for '*2^' and 'E' is the exponent in decimal } function PowerOf2Single ( const x: Single; n: Integer ): Single; { returns x * 2 ^ n }
procedure FlipBitSingle ( var x: Single; i: BitIndexSingle ); { flips bit i of x }
function SuccSingle ( const x: Single): Single;
{ returns successor of x }
function PredSingle ( const x: Single): Single;
{ returns predecessor of x }
Best regards,
Tom
