[m-dev.] integer conversions

Peter Wang novalazy at gmail.com
Mon May 25 17:35:11 AEST 2020


Hi,

I made a table of the predicates and functions for converting between
integer types (attached). Should we add any of the following, or others?

:- pred uint.to_int(uint::in, int::out) is semidet.
:- func uint.det_to_int(uint) = int.

:- pred uint32.to_int(uint32::in, int::out) is semidet.
:- pred uint64.to_int(uint32::in, int::out) is semidet.

    % The first three are synonyms for cast_to_uint.
:- func uint8.to_uint(uint8) = uint.
:- func uint16.to_uint(uint16) = uint.
:- func uint32.to_uint(uint32) = uint.
:- pred uint64.to_uint(uint64::in, uint::out) is semidet.

:- pred uint8.from_uint(uint::in, uint8::out) is semidet.
:- pred uint16.from_uint(uint::in, uint16::out) is semidet.
:- pred uint32.from_uint(uint::in, uint32::out) is semidet.
:- func uint64.from_uint(uint) = uint64.

:- func uint8.cast_from_uint(uint) = uint8.
:- func uint16.cast_from_uint(uint) = uint16.
:- func uint32.cast_from_uint(uint) = uint32.	% already exists
:- func uint64.cast_from_uint(uint) = uint64.   % synonym

    % Only for consistency with uint16 & uint32 modules
:- func uint8.cast_to_uint64(uint8) = uint64.
:- func uint8.cast_from_uint64(uint64) = uint8.

Peter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: int-conversions.pdf
Type: application/pdf
Size: 17710 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/developers/attachments/20200525/fee4fb17/attachment.pdf>


More information about the developers mailing list