1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

math.big: minor clean up

This commit is contained in:
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
*28 Nov 2020*
(V 0.2 RC)
- Builtin compile-time JSON serializer now supports `time.Time`
TODO
## V 0.1.27

View File

@ -106,18 +106,6 @@ pub fn from_string(input string) Number {
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 {
r := C.bignum_to_int(&n)
return r
@ -156,31 +144,31 @@ pub fn (n Number) hexstr() string {
// //////////////////////////////////////////////////////////
// overloaded ops for the numbers:
pub fn (a Number) +(b Number) Number {
pub fn (a Number) + (b Number) Number {
c := Number{}
C.bignum_add(&a, &b, &c)
return c
}
pub fn (a Number) -(b Number) Number {
pub fn (a Number) - (b Number) Number {
c := Number{}
C.bignum_sub(&a, &b, &c)
return c
}
pub fn (a Number) *(b Number) Number {
pub fn (a Number) * (b Number) Number {
c := Number{}
C.bignum_mul(&a, &b, &c)
return c
}
pub fn (a Number) /(b Number) Number {
pub fn (a Number) / (b Number) Number {
c := Number{}
C.bignum_div(&a, &b, &c)
return c
}
pub fn (a Number) %(b Number) Number {
pub fn (a Number) % (b Number) Number {
c := Number{}
C.bignum_mod(&a, &b, &c)
return c

View File

@ -78,10 +78,6 @@ fn test_mod() {
}
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('1').hexstr() == '1'
assert big.from_string('0').hexstr() == '0'