Example of the project nuts.Demo.Float128s for Lazarus

Conversions of Float64 values to Float128 values and, then, back to Float64 values.

//////////////////////////////////////////////////////////////////////////////// ===================== Float64 (conversions) ===================== ------------------- Compiler directives ------------------- NUTS_DEBUG : defined NUTS_THREAD_SAFE : not defined NUTS_ASM_CODE : not defined ------- Context ------- Masks = [feInexact,feUnderflow] Flags = [] Rounding mode = rmTiesToEven ------------ Random value ------------ x = -8.0300302852620298E-1 x (bits) = 1011111111101001101100100011001101101000010000110111110011100111 q = -8.030030285262029776660597235604655e-1 y = -8.0300302852620298E-1 y (bits) = 1011111111101001101100100011001101101000010000110111110011100111 Check (q is Float64) .. : TRUE Check (x = y) ......... : TRUE ------------------ 1000 random values ------------------ Check conversions : TRUE ----- -Zero ----- x = 0.0000000000000000 x (bits) = 1000000000000000000000000000000000000000000000000000000000000000 q = -0.0 y = 0.0000000000000000 y (bits) = 1000000000000000000000000000000000000000000000000000000000000000 Check (q is Float64) .. : TRUE Check (x = y) ......... : TRUE ------------ MinSubnormal ------------ x = 4.9406564584124654E-324 x (bits) = 0000000000000000000000000000000000000000000000000000000000000001 q = 4.94065645841246544176568792868221372e-324 y = 4.9406564584124654E-324 y (bits) = 0000000000000000000000000000000000000000000000000000000000000001 Check (q is Float64) .. : TRUE Check (x = y) ......... : TRUE ------------ MaxSubnormal ------------ x = 2.2250738585072009E-308 x (bits) = 0000000000001111111111111111111111111111111111111111111111111111 q = 2.22507385850720088902458687608585989e-308 y = 2.2250738585072009E-308 y (bits) = 0000000000001111111111111111111111111111111111111111111111111111 Check (q is Float64) .. : TRUE Check (x = y) ......... : TRUE --------- MinNormal --------- x = 2.2250738585072014E-308 x (bits) = 0000000000010000000000000000000000000000000000000000000000000000 q = 2.22507385850720138309023271733240406e-308 y = 2.2250738585072014E-308 y (bits) = 0000000000010000000000000000000000000000000000000000000000000000 Check (q is Float64) .. : TRUE Check (x = y) ......... : TRUE --------- MaxNormal --------- x = 1.7976931348623157E+308 x (bits) = 0111111111101111111111111111111111111111111111111111111111111111 q = 1.79769313486231570814527423731704357e+308 y = 1.7976931348623157E+308 y (bits) = 0111111111101111111111111111111111111111111111111111111111111111 Check (q is Float64) .. : TRUE Check (x = y) ......... : TRUE -------- Infinity -------- x = +Inf x (bits) = 0111111111110000000000000000000000000000000000000000000000000000 q = Infinity y = +Inf y (bits) = 0111111111110000000000000000000000000000000000000000000000000000 Check (q is Float64) .. : TRUE Check (x = y) ......... : TRUE ---- sNaN ---- x = Nan x (bits) = 0111111111110000000000000000000000000000000000000000000000000001 q = NaN y = Nan y (bits) = 0111111111111000000000000000000000000000000000000000000000000001 Check (q is Float64) ................. : TRUE Check ((x is sNaN) and (y is qNaN)) .. : TRUE ---- qNaN ---- x = Nan x (bits) = 0111111111111000000000000000000000000000000000000000000000000000 q = NaN y = Nan y (bits) = 0111111111111000000000000000000000000000000000000000000000000000 Check (q is Float64) ................. : TRUE Check ((x is qNaN) and (y is qNaN)) .. : TRUE ////////////////////////////////////////////////////////////////////////////////