Repository

vlang-big-integer

Big interger impelemented in pure vlang

CI Build status MIT License

Install

v install hanabi1224.biginteger

Import

import hanabi1224.biginteger

Usage

v1 := biginteger.from_int(-3)
// Note that '_' and ',' are allowed, only base-10 is currently supported.
v2 := biginteger.from_str("-23333333333333333333333333333333333333") 
v3 := biginteger.from_u64(9876554321)
// constants
zero := biginteger.zero
// + - * / %, TODO: pow etc.
println('$v2 + $ v3 = ${v2 + v3}')
println('$v2 - $ v3 = ${v2 - v3}')
println('$v2 * $ v3 = ${v2 * v3}')
println('$v2 / $ v3 = ${v2 / v3}')
println('$v2 % $ v3 = ${v2 % v3}')

// bit shifting TODO: bit and / or ops
println('v2 << 32 = ${v2.lshift(32)}')
println('v2 >> 2 = ${v2.rshift(2)}')

Examples

pidigits

v -prod -cc clang -gc boehm_full run ./examples/pidigits.v

About

0
2032
1 year ago

Author

hanabi1224