diff options
| -rw-r--r-- | Integer_Saturating_Arithmetic.jai (renamed from Math_Ext.jai) | 12 | ||||
| -rw-r--r-- | Test_IntSatArith.jai (renamed from Math_Test.jai) | 8 |
2 files changed, 9 insertions, 11 deletions
diff --git a/Math_Ext.jai b/Integer_Saturating_Arithmetic.jai index 20ccfe3..915b1a4 100644 --- a/Math_Ext.jai +++ b/Integer_Saturating_Arithmetic.jai @@ -1,8 +1,6 @@ -// Integer saturating arighmetic (with branch-free procedures on x64). -// Expects signed values in two's complement. +// Integer saturating arighmetic (with assembly branch-free procedures for x64 - expecting signed values in two's complement). #import "Basic"; -#import "Compiler"; #import "Math"; #import "String"; @@ -39,7 +37,7 @@ INTEGER_ARITHMETIC_TYPES_CHECK :: #string DONE return true; DONE -add :: (x: $Tx, y: $Ty, $USE_GENERIC: bool = false) -> result: $Tr, saturated: bool #modify { #insert INTEGER_ARITHMETIC_TYPES_CHECK; } // #dump +add :: (x: $Tx, y: $Ty, $USE_GENERIC: bool = false) -> result: $Tr, saturated: bool #modify { #insert INTEGER_ARITHMETIC_TYPES_CHECK; } { #if USE_GENERIC || CPU != .X64 { @@ -120,7 +118,7 @@ add :: (x: $Tx, y: $Ty, $USE_GENERIC: bool = false) -> result: $Tr, saturated: b } } -sub :: (x: $Tx, y: $Ty, $USE_GENERIC: bool = false) -> result: $Tr, overflow: bool #modify { #insert INTEGER_ARITHMETIC_TYPES_CHECK; } // #dump +sub :: (x: $Tx, y: $Ty, $USE_GENERIC: bool = false) -> result: $Tr, overflow: bool #modify { #insert INTEGER_ARITHMETIC_TYPES_CHECK; } { #if USE_GENERIC || CPU != .X64 { @@ -197,7 +195,7 @@ sub :: (x: $Tx, y: $Ty, $USE_GENERIC: bool = false) -> result: $Tr, overflow: bo } -mul :: (x: $Tx, y: $Ty, $USE_GENERIC: bool = false) -> result: $Tr, overflow: bool #modify { #insert INTEGER_ARITHMETIC_TYPES_CHECK; } // #dump +mul :: (x: $Tx, y: $Ty, $USE_GENERIC: bool = false) -> result: $Tr, overflow: bool #modify { #insert INTEGER_ARITHMETIC_TYPES_CHECK; } { #if USE_GENERIC || CPU != .X64 { @@ -288,7 +286,7 @@ mul :: (x: $Tx, y: $Ty, $USE_GENERIC: bool = false) -> result: $Tr, overflow: bo } } -div :: (x: $Tx, y: $Ty, $USE_GENERIC: bool = false) -> result: $Tr, remainder: Tr, saturated: bool #modify { #insert INTEGER_ARITHMETIC_TYPES_CHECK; } //#dump +div :: (x: $Tx, y: $Ty, $USE_GENERIC: bool = false) -> result: $Tr, remainder: Tr, saturated: bool #modify { #insert INTEGER_ARITHMETIC_TYPES_CHECK; } { #if USE_GENERIC || CPU != .X64 { diff --git a/Math_Test.jai b/Test_IntSatArith.jai index 5fe87c5..8e9125c 100644 --- a/Math_Test.jai +++ b/Test_IntSatArith.jai @@ -1,11 +1,10 @@ -// Tests for integer saturating arighmetic (with branch-free procedures on x64). -// Expects signed values in two's complement. +// Tests for integer saturating arighmetic procedures. #import "Basic"; #import "Compiler"; #import "Math"; #import "String"; -#load "Math_Ext.jai"; +#load "Integer_Saturating_Arithmetic.jai"; main :: () { @@ -193,7 +192,8 @@ main :: () { numbers_y: [..] type; array_reserve(*numbers_x, DATA_SIZE); array_reserve(*numbers_y, DATA_SIZE); - + + // Comment the line bellow to use the same "random" values. random_seed(cast(u64)to_nanoseconds(current_time_monotonic())); for 0..DATA_SIZE-1 { |
