From 939e10cb284a506c2751c642c22f16caa096239f Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Tue, 22 Dec 2020 08:27:50 +0100 Subject: [PATCH] math.big: minor clean up --- CHANGELOG.md | 1 + vlib/math/big/big.v | 22 +++++----------------- vlib/math/big/big_test.v | 4 ---- 3 files changed, 6 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a9557f3738..6804d94826 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/vlib/math/big/big.v b/vlib/math/big/big.v index d6c3f6334a..0df769cc2a 100644 --- a/vlib/math/big/big.v +++ b/vlib/math/big/big.v @@ -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 diff --git a/vlib/math/big/big_test.v b/vlib/math/big/big_test.v index 5b24961ee6..da550160d1 100644 --- a/vlib/math/big/big_test.v +++ b/vlib/math/big/big_test.v @@ -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'