Comparing version 0.2.11 to 0.2.12
@@ -96,2 +96,8 @@ import { u128Safe as u128 } from '..'; | ||
it("Should div two safe u128s", () => { | ||
var a = u128.from("2222222"); | ||
var b = u128.One; | ||
expect(u128.div(a,b)).toStrictEqual(a); | ||
}); | ||
it("Should power number 1", () => { | ||
@@ -98,0 +104,0 @@ expect<u128>(u128.Zero ** 1024).toStrictEqual(u128.Zero); |
@@ -143,2 +143,42 @@ import { u256Safe as u256 } from './u256'; | ||
@inline @operator('|') | ||
static or(a: u128, b: u128): u128 { | ||
return changetype<u128>(U128.or(a, b)); | ||
} | ||
@inline @operator('^') | ||
static xor(a: u128, b: u128): u128 { | ||
return changetype<u128>(U128.xor(a, b)); | ||
} | ||
@inline @operator('&') | ||
static and(a: u128, b: u128): u128 { | ||
return changetype<u128>(U128.and(a, b)); | ||
} | ||
@inline @operator('<<') | ||
static shl(value: u128, shift: i32): u128 { | ||
return changetype<u128>(U128.shl(value, shift)); | ||
} | ||
@inline @operator('>>') | ||
static shr(value: u128, shift: i32): u128 { | ||
return changetype<u128>(U128.shr(value, shift)); | ||
} | ||
@inline @operator('>>>') | ||
static shr_u(value: u128, shift: i32): u128 { | ||
return u128.shr(value, shift); | ||
} | ||
@inline | ||
static rotl(value: u128, shift: i32): u128 { | ||
return changetype<u128>(U128.rotl(value, shift)); | ||
} | ||
@inline | ||
static rotr(value: u128, shift: i32): u128 { | ||
return changetype<u128>(U128.rotr(value, shift)); | ||
} | ||
@operator.prefix('++') | ||
@@ -230,2 +270,7 @@ preInc(): this { | ||
@inline @operator('/') | ||
static div(a: u128, b: u128): u128 { | ||
return changetype<u128>(U128.div(a, b)); | ||
} | ||
@operator('**') | ||
@@ -239,3 +284,24 @@ static pow(base: u128, exponent: i32): u128 { | ||
@inline @operator('%') | ||
static rem(a: u128, b: u128): u128 { | ||
return changetype<u128>(U128.rem(a, b)); | ||
} | ||
@inline | ||
static div10(value: u128): u128 { | ||
return changetype<u128>(U128.div10(value)); | ||
} | ||
@inline | ||
static rem10(value: u128): u128 { | ||
return changetype<u128>(U128.rem10(value)); | ||
} | ||
// compute floor(sqrt(x)) | ||
static sqrt(value: u128): u128 { | ||
return changetype<u128>(U128.sqrt(value)); | ||
} | ||
@inline | ||
toUnchecked(): U128 { | ||
@@ -242,0 +308,0 @@ return changetype<U128>(this); |
{ | ||
"name": "as-bignum", | ||
"version": "0.2.11", | ||
"version": "0.2.12", | ||
"description": "128 and 256 bits integer and fixed point arithmetics for AssemblyScript. Also support checking overflow/underflow", | ||
@@ -5,0 +5,0 @@ "main": "js/index.js", |
748236
4126