bigints icon indicating copy to clipboard operation
bigints copied to clipboard

BigInts for Nim

Results 28 bigints issues
Sort by recently updated
recently updated
newest added

Test on i386 (a 32 bit arch) in the CI and update the versions tested. Closes #48. The CI job uses the prebuilt binaries from https://nim-lang.org/install.html (since most actions aren't...

Unify the various `initBigInt` versions that convert an integer to a `BigInt` into one `func`.

- Export `isNegative` and `isZero` because it is easier to export here than to reimplement downstream. - Add `toBytes` proc for serializing. This is used by the CBOR package. Also...

* avoid redundant `modulo` call if `exponent >= 0` * avoid shifting `exponent` Unfortunately, I didn't notice any difference in performance, but this should reduce the number of allocations.

See https://github.com/status-im/nim-stint/issues/126. There are quite some optimizations we can implement to speed up `powmod`, for example [Montgomery multiplication](https://en.wikipedia.org/wiki/Montgomery_modular_multiplication).

Currently, there are `inc`, `dec`, `succ`, `pred` for adding/subtracting an `int`. Internally, there are also functions for comparing with `int32`. We should add more functions for working with `BigInt`s and...

#### Hello, #### I encountered a problem while using the bigints library. When I tried to use the toInt function to convert a value of type BigInt to type int,...

```nim import bigints var a = initBigint("6277101735386680763835789123314955362437298222279840143829") var b = initBigint("1461501637330902918203684832716283019655932313743") var r = a.div(b) ``` Output: ``` Error: unhandled exception: /home/jhg/.nimble/pkgs/bigints-1.0.0/bigints.nim(652, 14) `q1

I added random as std dependency. It is now possible to generate a BigInt which is exactly nbits long. I also added a file for tests specific for probabilistic tests.

I benchmarked multiplication, division, random generation of bigints. Without flags, the operations are slow, with flags, the timings looks correct to me. The code source quality of benchBigints.nim can be...