From c073535b2e866ad83655388b76bd53301f1a74f6 Mon Sep 17 00:00:00 2001 From: Yu Zhang Date: Sat, 25 Jan 2025 10:00:44 +0800 Subject: [PATCH] add min and max value for int16 and uint16 --- int16/int16.mbt | 6 ++++++ int16/int16.mbti | 3 +++ uint16/uint16.mbt | 6 ++++++ uint16/uint16.mbti | 3 +++ 4 files changed, 18 insertions(+) diff --git a/int16/int16.mbt b/int16/int16.mbt index c1b491685..9183c3c9b 100644 --- a/int16/int16.mbt +++ b/int16/int16.mbt @@ -12,6 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. +///| +pub let max_value : Int16 = 32767 + +///| +pub let min_value : Int16 = -32768 + ///| pub fn op_add(self : Int16, that : Int16) -> Int16 { (self.to_int() + that.to_int()).to_int16() diff --git a/int16/int16.mbti b/int16/int16.mbti index 0acc3b4bc..487434153 100644 --- a/int16/int16.mbti +++ b/int16/int16.mbti @@ -1,6 +1,9 @@ package moonbitlang/core/int16 // Values +let max_value : Int16 + +let min_value : Int16 // Types and methods impl Int16 { diff --git a/uint16/uint16.mbt b/uint16/uint16.mbt index 2467f2902..ed7a080c6 100644 --- a/uint16/uint16.mbt +++ b/uint16/uint16.mbt @@ -12,6 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. +///| +pub let max_value : UInt16 = 65535 + +///| +pub let min_value : UInt16 = 0 + ///| pub fn op_add(self : UInt16, that : UInt16) -> UInt16 { (self.to_int() + that.to_int()).to_uint16() diff --git a/uint16/uint16.mbti b/uint16/uint16.mbti index 09351aecc..bca523ec4 100644 --- a/uint16/uint16.mbti +++ b/uint16/uint16.mbti @@ -1,6 +1,9 @@ package moonbitlang/core/uint16 // Values +let max_value : UInt16 + +let min_value : UInt16 // Types and methods impl UInt16 {