Skip to content

Commit 6dd8c1b

Browse files
committed
Change 'Number.maxInt'and 'Number.minInt' back to off-by-one
1 parent 84916f8 commit 6dd8c1b

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

lib/Number.trp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
(** In Troupe, there is not per-se an `int` type. Rather, there is a `number` and some integral
22
* operations on them which treats them as if they were 32 bit signed integers. *)
33

4-
let (** Largest (safe) possible integral value. Anything larger than this cannot represent an
4+
let (** Largest (safe) possible integral value. Anything larger than +1 of this cannot represent an
55
* increment of 1.
66
*
77
* NOTE: Value copied from the JavaScript documentation for `Number.MAX_SAFE_INTEGER`. *)
8-
val maxInt = 9007199254740992
8+
val maxInt = 9007199254740991
99

10-
(** Smallest (safe) possible integral value. Anything smaller than this cannot represent an
10+
(** Smallest (safe) possible integral value. Anything smaller than -1 this cannot represent an
1111
* increment of 1. *)
1212
val minInt = -maxInt
1313

tests/lib/Number.trp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ import Number
33

44
let val tests = Unit.group "Number" [
55
Unit.group "maxInt / minInt" [
6-
Unit.it "maxInt++ = maxInt" (Unit.isEq Number.maxInt (Number.maxInt + 1))
7-
, Unit.it "minInt-- = minInt" (Unit.isEq Number.minInt (Number.minInt - 1))
6+
Unit.it "maxInt++ != maxInt" (Unit.isNeq Number.maxInt (Number.maxInt + 1))
7+
, Unit.it "minInt-- != minInt" (Unit.isNeq Number.minInt (Number.minInt - 1))
8+
, Unit.it "maxInt+2 == maxInt+1" (Unit.isEq (Number.maxInt + 1) (Number.maxInt + 2))
9+
, Unit.it "minInt-2 == minInt+1" (Unit.isEq (Number.minInt - 1) (Number.minInt - 2))
810
],
911
Unit.group "abs" [
1012
Unit.it "keeps 0 as is" (Unit.isEq 0 (Number.abs 0))

0 commit comments

Comments
 (0)