diff options
Diffstat (limited to 'stdlib/source/lux/data/number/i64.lux')
-rw-r--r-- | stdlib/source/lux/data/number/i64.lux | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/stdlib/source/lux/data/number/i64.lux b/stdlib/source/lux/data/number/i64.lux index 32b9df2e3..aba61ad3e 100644 --- a/stdlib/source/lux/data/number/i64.lux +++ b/stdlib/source/lux/data/number/i64.lux @@ -1,6 +1,6 @@ (.module: [lux (#- and or not)]) -(def: #export width Nat +64) +(def: #export width Nat 64) ## [Values] (do-template [<name> <op> <doc>] @@ -32,15 +32,15 @@ (def: #export (count subject) {#.doc "Count the number of 1s in a bit-map."} (-> (I64 Any) Nat) - (let [count' (n/- (|> subject (logical-right-shift +1) (..and +6148914691236517205) i64) + (let [count' (n/- (|> subject (logical-right-shift 1) (..and 6148914691236517205) i64) (i64 subject))] (|> count' - (logical-right-shift +2) (..and +3689348814741910323) (n/+ (..and +3689348814741910323 count')) - (add-shift +4) (..and +1085102592571150095) - (add-shift +8) - (add-shift +16) - (add-shift +32) - (..and +127)))) + (logical-right-shift 2) (..and 3689348814741910323) (n/+ (..and 3689348814741910323 count')) + (add-shift 4) (..and 1085102592571150095) + (add-shift 8) + (add-shift 16) + (add-shift 32) + (..and 127)))) (def: #export not {#.doc "Bitwise negation."} @@ -49,7 +49,7 @@ (def: (flag idx) (-> Nat I64) - (|> +1 (:coerce I64) (left-shift idx))) + (|> 1 (:coerce I64) (left-shift idx))) (def: #export (clear idx input) {#.doc "Clear bit at given index."} @@ -68,7 +68,7 @@ (def: #export (set? idx input) (-> Nat (I64 Any) Bit) - (|> input (:coerce I64) (..and (flag idx)) (n/= +0) .not)) + (|> input (:coerce I64) (..and (flag idx)) (n/= 0) .not)) (do-template [<name> <main> <comp>] [(def: #export (<name> distance input) @@ -84,4 +84,4 @@ (def: #export (region size offset) (-> Nat Nat I64) - (|> +1 (:coerce I64) (left-shift size) dec (left-shift offset))) + (|> 1 (:coerce I64) (left-shift size) dec (left-shift offset))) |