[m-rev.] for review: fix some comments in {int,uint}.m
Adrian Wong
adrianwjw at gmail.com
Fri Jul 13 08:38:55 AEST 2018
As below. Apologies if I'm going about this review process incorrectly.
Kind regards,
Adrian
--------------------
Fix some comments in {int,uint}.m.
library/int8.m:
library/int16.m:
library/int64.m:
library/uint8.m:
library/uint16.m:
library/uint32.m:
library/uint64.m:
As above.
diff --git a/library/int16.m b/library/int16.m
index a40b82cf1..fdd54d51c 100644
--- a/library/int16.m
+++ b/library/int16.m
@@ -30,7 +30,7 @@
%
:- pred from_int(int::in, int16::out) is semidet.
- % det_from_int(I, I16):
+ % det_from_int(I) = I16:
%
% Convert an int to an int16.
% Throws an exception if I is not in [-(2^15), 2^15 - 1].
diff --git a/library/int64.m b/library/int64.m
index 28d1eaba5..e894bea73 100644
--- a/library/int64.m
+++ b/library/int64.m
@@ -53,9 +53,11 @@
% cast_to_int(I64) = I:
%
- % Convert an int64 to an int. Since an int can be only 32 or 64 bits,
- % this is guaranteed to yield a result that is mathematically equal
- % to the original.
+ % Convert an int64 to an int.
+ % Always succeeds. If ints are 64 bits, I will always be
+ % mathematically equal to I64. However, if ints are 32 bits,
+ % then I will be mathematically equal to I64 only if
+ % I64 is in [-(2^31), 2^31 - 1].
%
:- func cast_to_int(int64) = int.
diff --git a/library/int8.m b/library/int8.m
index 46f06af85..9c3769469 100644
--- a/library/int8.m
+++ b/library/int8.m
@@ -30,7 +30,7 @@
%
:- pred from_int(int::in, int8::out) is semidet.
- % from_int(I, I8):
+ % det_from_int(I) = I8:
%
% Convert an int to an int8.
% Throws an exception if I is not in [-(2^7), 2^7 - 1].
diff --git a/library/uint16.m b/library/uint16.m
index 63f24c736..f179e32ae 100644
--- a/library/uint16.m
+++ b/library/uint16.m
@@ -26,14 +26,14 @@
% from_int(I, U16):
%
% Convert an int into a uint16.
- % Fails if I is not in [0, 2^15 - 1].
+ % Fails if I is not in [0, 2^16 - 1].
%
:- pred from_int(int::in, uint16::out) is semidet.
- % from_int(I, U16):
+ % det_from_int(I) = U16:
%
% Convert an int into a uint16.
- % Throws an exception if I is not in [0, 2^15 - 1].
+ % Throws an exception if I is not in [0, 2^16 - 1].
%
:- func det_from_int(int) = uint16.
@@ -41,7 +41,7 @@
%
% Convert an int to a uint16.
% Always succeeds, but will yield a result that is mathematically equal
- % to I only if I is in [0, 2^15 - 1].
+ % to I only if I is in [0, 2^16 - 1].
%
:- func cast_from_int(int) = uint16.
@@ -87,7 +87,7 @@
% cast_from_int16(I16) = U16:
%
% Convert an int16 to a uint16. This will yield a result that is
- % mathematically equal to I16 only if I16 is in [0, 2^15 -1].
+ % mathematically equal to I16 only if I16 is in [0, 2^15 - 1].
%
:- func cast_from_int16(int16) = uint16.
diff --git a/library/uint32.m b/library/uint32.m
index 4ebb2dcdc..c711cba31 100644
--- a/library/uint32.m
+++ b/library/uint32.m
@@ -26,14 +26,14 @@
% from_int(I, U32):
%
% Convert an int into a uint32.
- % Fails if I is not in [0, 2^31 - 1].
+ % Fails if I is not in [0, 2^32 - 1].
%
:- pred from_int(int::in, uint32::out) is semidet.
- % from_int(I, U32):
+ % det_from_int(I) = U32:
%
% Convert an int into a uint32.
- % Throws an exception if I is not in [0, 2^31 - 1].
+ % Throws an exception if I is not in [0, 2^32 - 1].
%
:- func det_from_int(int) = uint32.
@@ -41,7 +41,7 @@
%
% Convert an int to a uint32.
% Always succeeds, but will yield a result that is mathematically equal
- % to I only if I is in [0, 2^31 - 1].
+ % to I only if I is in [0, 2^32 - 1].
%
:- func cast_from_int(int) = uint32.
@@ -81,7 +81,7 @@
% cast_from_int32(I32) = U32:
%
% Convert an int32 to a uint32. This will yield a result that is
- % mathematically equal to I32 only if I32 is in [0, 2^31 -1].
+ % mathematically equal to I32 only if I32 is in [0, 2^31 - 1].
%
:- func cast_from_int32(int32) = uint32.
diff --git a/library/uint64.m b/library/uint64.m
index c91d4703d..450dbac65 100644
--- a/library/uint64.m
+++ b/library/uint64.m
@@ -26,14 +26,14 @@
% from_int(I, U64):
%
% Convert an int into a uint64.
- % Fails if I is not in [0, 2^63 - 1].
+ % Fails if I is not in [0, 2^64 - 1].
%
:- pred from_int(int::in, uint64::out) is semidet.
- % det_from_int(I, U64):
+ % det_from_int(I) = U64:
%
% Convert an int into a uint64.
- % Throws an exception if I is not in [0, 2^63 - 1].
+ % Throws an exception if I is not in [0, 2^64 - 1].
%
:- func det_from_int(int) = uint64.
@@ -41,7 +41,7 @@
%
% Convert an int to a uint64.
% Always succeeds, but will yield a result that is mathematically equal
- % to I only if I is in [0, 2^63 - 1].
+ % to I only if I is in [0, 2^64 - 1].
%
:- func cast_from_int(int) = uint64.
@@ -53,8 +53,10 @@
% cast_to_int(U64) = I:
%
% Convert a uint64 to an int.
- % Always succeeds, but will yield a result that is mathematically equal
- % to U64 only if U64 is in [0, 2^63 - 1].
+ % Always succeeds. If ints are 64 bits, I will be mathematically
+ % equal to U64 only if U64 is in [0, 2^63 - 1]. If ints are 32
+ % bits, I will be mathematically equal to U64 only if U64 is in
+ % [0, 2^31 - 1].
%
:- func cast_to_int(uint64) = int.
@@ -79,7 +81,7 @@
% cast_from_int64(I64) = U64:
%
% Convert an int64 to a uint64. This will yield a result that is
- % mathematically equal to I64 only if I64 is in [0, 2^63 -1].
+ % mathematically equal to I64 only if I64 is in [0, 2^63 - 1].
%
:- func cast_from_int64(int64) = uint64.
diff --git a/library/uint8.m b/library/uint8.m
index 1c8701f99..16e6da2d7 100644
--- a/library/uint8.m
+++ b/library/uint8.m
@@ -26,14 +26,14 @@
% from_int(I, U8):
%
% Convert an int to a uint8.
- % Fails if I is not in [0, 2^7 - 1].
+ % Fails if I is not in [0, 2^8 - 1].
%
:- pred from_int(int::in, uint8::out) is semidet.
- % from_int(I, U8):
+ % det_from_int(I) = U8:
%
% Convert an int to a uint8.
- % Throws an exception if I is not in [0, 2^7 - 1].
+ % Throws an exception if I is not in [0, 2^8 - 1].
%
:- func det_from_int(int) = uint8.
@@ -41,7 +41,7 @@
%
% Convert an int to a uint8.
% Always succeeds, but will yield a result that is mathematically equal
- % to I only if I is in [0, 2^7 - 1].
+ % to I only if I is in [0, 2^8 - 1].
%
:- func cast_from_int(int) = uint8.
@@ -87,7 +87,7 @@
% cast_from_int8(I8) = U8:
%
% Convert an int8 to a uint8. This will yield a result that is
- % mathematically equal to I8 only if I8 is in [0, 2^7 -1].
+ % mathematically equal to I8 only if I8 is in [0, 2^7 - 1].
%
:- func cast_from_int8(int8) = uint8.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20180713/4615511c/attachment.html>
More information about the reviews
mailing list