Files
mercury/tests/hard_coded/float_conv.exp
Julien Fischer 8fe2751758 Conversion of 8- and 16-bit integers to floats.
Add functions for performing conversion of 8- and 16-bit integers to floats.
Since the ranges of all these integer types lie within the what can be exactly
represented by both single- and double-precision floating-point values, these
conversions always succeed.

Add a note about the float/1 function.

library/float.m:
     Add the new conversion functions.

     Note that the behaviour of float/1 is currently undefined if the
     argument is outside the range that the floating-point type can exactly
     represent integers.

     Fix section headings.

tests/hard_coded/Mmakfile:;
tests/hard_coded/float_conv.{m,exp}
    A test of int->float conversion; currently for 8- and 16-bit integers.
2018-10-09 04:42:31 +00:00

43 lines
958 B
Plaintext

*** Testing int8 -> float conversion ***
from_int8(-128i8) = -128.0
from_int8(-1i8) = -1.0
from_int8(0i8) = 0.0
from_int8(8i8) = 8.0
from_int8(16i8) = 16.0
from_int8(32i8) = 32.0
from_int8(64i8) = 64.0
from_int8(127i8) = 127.0
*** Testing uint8 -> float conversion ***
from_uint8(0u8) = 0.0
from_uint8(1u8) = 1.0
from_uint8(2u8) = 2.0
from_uint8(8u8) = 8.0
from_uint8(23u8) = 23.0
from_uint8(127u8) = 127.0
from_uint8(128u8) = 128.0
from_uint8(255u8) = 255.0
*** Testing int16 -> float conversion ***
from_int16(-32768i16) = -32768.0
from_int16(-129i16) = -129.0
from_int16(-128i16) = -128.0
from_int16(-1i16) = -1.0
from_int16(0i16) = 0.0
from_int16(1i16) = 1.0
from_int16(127i16) = 127.0
from_int16(128i16) = 128.0
from_int16(32767i16) = 32767.0
*** Testing uint16 -> float conversion ***
from_uint16(0u16) = 0.0
from_uint16(1u16) = 1.0
from_uint16(8u16) = 8.0
from_uint16(127u16) = 127.0
from_uint16(128u16) = 128.0
from_uint16(32767u16) = 32767.0