Merge pull request #2354 from rtfeldman/add_builtin_Num.minI128

Add `Num.minI128` builtin
This commit is contained in:
Richard Feldman 2022-01-16 22:38:27 -05:00 committed by GitHub
commit 2ade76b373
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 80 additions and 0 deletions

View file

@ -65,6 +65,7 @@ interface Num
maxI128,
maxInt,
minFloat,
minI128,
minInt,
modInt,
modFloat,
@ -822,6 +823,25 @@ maxU32 : U32
## and zero is the lowest unsigned number. Unsigned numbers cannot be negative.
minU32 : U32
## The highest number that can be stored in an #I128 without overflowing its
## available memory and crashing.
##
## For reference, this number is `170_141_183_460_469_231_731_687_303_715_884_105_727`,
## which is over 2 million.
##
## Note that this is smaller than the positive version of #Int.minI128,
## which means if you call #Num.abs on #Int.minI128, it will overflow and crash!
maxI128 : I128
## The min number that can be stored in an #I128 without underflowing its
## available memory and crashing.
##
## For reference, this number is `-170_141_183_460_469_231_731_687_303_715_884_105_728`.
##
## Note that the positive version of this number is larger than #Int.maxI128,
## which means if you call #Num.abs on #Int.minI128, it will overflow and crash!
minI128 : I128
## The highest supported #F64 value you can have, which is approximately 1.8 × 10^308.
##
## If you go higher than this, your running Roc code will crash - so be careful not to!

View file

@ -397,6 +397,9 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
Box::new(bool_type()),
);
// minI128 : I128
add_type!(Symbol::NUM_MIN_I128, i128_type());
// maxI128 : I128
add_type!(Symbol::NUM_MAX_I128, i128_type());