math.big: minor clean up

pull/7467/head
Alexander Medvednikov 2020-12-22 08:27:50 +01:00
parent b3e0926601
commit 939e10cb28
3 changed files with 6 additions and 21 deletions

View File

@ -1,6 +1,7 @@
## V 0.1.30 ## V 0.1.30
*28 Nov 2020* *28 Nov 2020*
(V 0.2 RC) (V 0.2 RC)
- Builtin compile-time JSON serializer now supports `time.Time`
TODO TODO
## V 0.1.27 ## V 0.1.27

View File

@ -106,18 +106,6 @@ pub fn from_string(input string) Number {
return n return n
} }
pub fn from_string2(input string) Number {
mut n := Number{}
C.bignum_init(&n)
if input.len == 0 {
return from_int(0)
}
for i, c in input {
n.array[i] = u32(c - `0`)
}
return n
}
pub fn (n Number) int() int { pub fn (n Number) int() int {
r := C.bignum_to_int(&n) r := C.bignum_to_int(&n)
return r return r
@ -156,31 +144,31 @@ pub fn (n Number) hexstr() string {
// ////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////
// overloaded ops for the numbers: // overloaded ops for the numbers:
pub fn (a Number) +(b Number) Number { pub fn (a Number) + (b Number) Number {
c := Number{} c := Number{}
C.bignum_add(&a, &b, &c) C.bignum_add(&a, &b, &c)
return c return c
} }
pub fn (a Number) -(b Number) Number { pub fn (a Number) - (b Number) Number {
c := Number{} c := Number{}
C.bignum_sub(&a, &b, &c) C.bignum_sub(&a, &b, &c)
return c return c
} }
pub fn (a Number) *(b Number) Number { pub fn (a Number) * (b Number) Number {
c := Number{} c := Number{}
C.bignum_mul(&a, &b, &c) C.bignum_mul(&a, &b, &c)
return c return c
} }
pub fn (a Number) /(b Number) Number { pub fn (a Number) / (b Number) Number {
c := Number{} c := Number{}
C.bignum_div(&a, &b, &c) C.bignum_div(&a, &b, &c)
return c return c
} }
pub fn (a Number) %(b Number) Number { pub fn (a Number) % (b Number) Number {
c := Number{} c := Number{}
C.bignum_mod(&a, &b, &c) C.bignum_mod(&a, &b, &c)
return c return c

View File

@ -78,10 +78,6 @@ fn test_mod() {
} }
fn test_from_str() { fn test_from_str() {
x := big.from_string2('23')
println('kek')
println(x.str())
exit(0)
assert big.from_string('').hexstr() == '0' assert big.from_string('').hexstr() == '0'
assert big.from_string('1').hexstr() == '1' assert big.from_string('1').hexstr() == '1'
assert big.from_string('0').hexstr() == '0' assert big.from_string('0').hexstr() == '0'