aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/math/number/i64.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/math/number/i64.lux49
1 files changed, 24 insertions, 25 deletions
diff --git a/stdlib/source/lux/math/number/i64.lux b/stdlib/source/lux/math/number/i64.lux
index d04a9c13a..e8dde83e0 100644
--- a/stdlib/source/lux/math/number/i64.lux
+++ b/stdlib/source/lux/math/number/i64.lux
@@ -26,22 +26,29 @@
(All [s] (-> <parameter_type> (I64 s) (I64 s)))
(<op> parameter subject))]
- [(I64 Any) or "lux i64 or" "Bitwise or."]
- [(I64 Any) xor "lux i64 xor" "Bitwise xor."]
- [(I64 Any) and "lux i64 and" "Bitwise and."]
+ [(I64 Any) or "lux i64 or" "Bitwise or."]
+ [(I64 Any) xor "lux i64 xor" "Bitwise xor."]
+ [(I64 Any) and "lux i64 and" "Bitwise and."]
- [Nat left_shift "lux i64 left-shift" "Bitwise left-shift."]
- [Nat logic_right_shift "lux i64 logical-right-shift" "Unsigned bitwise logic-right-shift."]
- [Nat arithmetic_right_shift "lux i64 arithmetic-right-shift" "Signed bitwise arithmetic-right-shift."]
+ [Nat left_shift "lux i64 left-shift" "Bitwise left-shift."]
+ [Nat right_shift "lux i64 right-shift" "Unsigned/logic bitwise right-shift."]
)
+(type: #export Mask
+ I64)
+
+(def: #export (bit position)
+ (-> Nat Mask)
+ (|> 1 .i64 (..left_shift (n.% ..width position))))
+
+(def: #export sign
+ Mask
+ (..bit (dec ..width)))
+
(def: #export not
{#.doc "Bitwise negation."}
(All [s] (-> (I64 s) (I64 s)))
- (xor (.i64 (dec 0))))
-
-(type: #export Mask
- I64)
+ (..xor (.i64 (dec 0))))
(def: #export false
Mask
@@ -59,25 +66,17 @@
0 ..true
bits (|> 1 .i64 (..left_shift (n.% ..width bits)) .dec))))
-(def: #export (bit position)
- (-> Nat Mask)
- (|> 1 .i64 (..left_shift (n.% ..width position))))
-
-(def: #export sign
- Mask
- (..bit (dec ..width)))
-
(def: (add_shift shift value)
(-> Nat Nat Nat)
- (|> value (logic_right_shift shift) (n.+ value)))
+ (|> value (right_shift shift) (n.+ value)))
(def: #export (count subject)
{#.doc "Count the number of 1s in a bit-map."}
(-> (I64 Any) Nat)
- (let [count' (n.- (|> subject (logic_right_shift 1) (..and 6148914691236517205) i64)
+ (let [count' (n.- (|> subject (right_shift 1) (..and 6148914691236517205) i64)
(i64 subject))]
(|> count'
- (logic_right_shift 2) (..and 3689348814741910323) (n.+ (..and 3689348814741910323 count'))
+ (right_shift 2) (..and 3689348814741910323) (n.+ (..and 3689348814741910323 count'))
(add_shift 4) (..and 1085102592571150095)
(add_shift 8)
(add_shift 16)
@@ -113,8 +112,8 @@
(..or (<forward> distance input)
(<backward> (n.- (n.% ..width distance) ..width) input)))]
- [rotate_left ..left_shift ..logic_right_shift]
- [rotate_right ..logic_right_shift ..left_shift]
+ [rotate_left ..left_shift ..right_shift]
+ [rotate_right ..right_shift ..left_shift]
)
(def: #export (region size offset)
@@ -166,7 +165,7 @@
high (try.assume (\ n.binary decode pattern))
low (..rotate_right size high)]
(function (_ value)
- (..or (..logic_right_shift size (..and high value))
+ (..or (..right_shift size (..and high value))
(..left_shift size (..and low value)))))))
swap/01 (swapper 0)
@@ -205,7 +204,7 @@
(def: &equivalence ..equivalence)
(def: width width)
(def: (narrow value)
- (..or (|> value (..and ..sign) (..logic_right_shift sign_shift))
+ (..or (|> value (..and ..sign) (..right_shift sign_shift))
(|> value (..and mantissa))))
(def: (widen value)
(.i64 (case (.nat (..and sign value))