Files
mercury/tests/hard_coded/uint16_from_bytes.m
Julien Fischer 8506fb5298 Add conversion functions from bytes (uint8s) to 16-bit integers.
library/int16.m:
library/uint16.m:
     As above.

tests/hard_coded/Mmakefile:
tests/hard_coded/int16_from_bytes.{m,exp}:
tests/hard_coded/uint16_from_bytes.{m,exp}:
     Test the new functions.
2017-10-10 19:26:38 -04:00

21 lines
495 B
Mathematica

:- module uint16_from_bytes.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
:- import_module uint16.
main(!IO) :-
Test1 = uint16.from_bytes_le(0x00u8, 0xffu8),
io.write_line(Test1, !IO),
Test2 = uint16.from_bytes_le(0xffu8, 0x00u8),
io.write_line(Test2, !IO),
Test3 = uint16.from_bytes_be(0x00u8, 0xffu8),
io.write_line(Test3, !IO),
Test4 = uint16.from_bytes_be(0xffu8, 0x00u8),
io.write_line(Test4, !IO).