Questions tagged [bignum]

Common computer-jargon term to refer to arbitrary-precision math and data-types. The term "arbitrary-precision" refers to the ability of a machine to perform numerical computations whose precision is limited only by the available memory.

362 questions
201
votes
6 answers

What is the difference between Int and Integer?

In Haskell, what is the difference between an Int and an Integer? Where is the answer documented?
0xAX
  • 20,957
  • 26
  • 117
  • 206
106
votes
8 answers

Arbitrary-precision arithmetic Explanation

I'm trying to learn C and have come across the inability to work with REALLY big numbers (i.e., 100 digits, 1000 digits, etc.). I am aware that there exist libraries to do this, but I want to attempt to implement it myself. I just want to know if…
TT.
  • 1,339
  • 3
  • 13
  • 13
83
votes
14 answers

How to implement big int in C++

I'd like to implement a big int class in C++ as a programming exercise—a class that can handle numbers bigger than a long int. I know that there are several open source implementations out there already, but I'd like to write my own. I'm trying to…
oneself
  • 38,641
  • 34
  • 96
  • 120
62
votes
8 answers

Working with large numbers in PHP

To use modular exponentiation as you would require when using the Fermat Primality Test with large numbers (100,000+), it calls for some very large calculations. When I multiply two large numbers (eg: 62574 and 62574) PHP seems to cast the result to…
nickf
  • 537,072
  • 198
  • 649
  • 721
57
votes
1 answer

What is the standard solution in JavaScript for handling big numbers (BigNum)?

Is there a bignum built into JavaScript or browsers? The alternate is loading an external library like but that seems slow and may trigger a security warning. I've considered…
David Cary
  • 5,250
  • 6
  • 53
  • 66
29
votes
3 answers

How to deal with big numbers in javascript

I'm looking for a Mathematical solution that deals with really (long, big, huge, storms) numbers. I haven't found anything yet, But I don't wanna think that this problem hasn't be solve at this time. I'm looking for an easy Number solution, like…
crsuarezf
  • 1,201
  • 3
  • 18
  • 33
28
votes
2 answers

What does GCC __attribute__((mode(XX)) actually do?

This arose from a question earlier today on the subject of bignum libraries and gcc specific hacks to the C language. Specifically, these two declarations were used: typedef unsigned int dword_t __attribute__((mode(DI))); On 32 bit systems…
user257111
27
votes
5 answers

How can I represent a very large integer in .NET?

Does .NET come with a class capable of representing extremely large integers, such as 100 factorial? If not, what are some good third party libraries to accomplish this?
Corey
  • 14,101
  • 7
  • 38
  • 35
26
votes
4 answers

Unable to call contract function from web3 with big number as parameter

I am trying to call a custom function of a contract that expects a parameter of unit256. I'm calling this function from web3 with this value as parameter: 10000000000000000000 (10 with 18 zeros) As soon as this call is hit by web3, I faced following…
Fariha Abbasi
  • 1,212
  • 2
  • 13
  • 19
26
votes
6 answers

What is the standard (or best supported) big number (arbitrary precision) library for Lua?

I'm working with large numbers that I can't have rounded off. Using Lua's standard math library, there seem to be no convenient way to preserve precision past some internal limit. I also see there are several libraries that can be loaded to work…
Jon 'links in bio' Ericson
  • 20,880
  • 12
  • 98
  • 148
24
votes
1 answer

Can long integer routines benefit from SSE?

I'm still working on routines for arbitrary long integers in C++. So far, I have implemented addition/subtraction and multiplication for 64-bit Intel CPUs. Everything works fine, but I wondered if I can speed it a bit by using SSE. I browsed through…
cxxl
  • 4,939
  • 3
  • 31
  • 52
21
votes
3 answers

Recursive function calculating factorials leads to stack overflow

I tried a recursive factorial algorithm in Rust. I use this version of the compiler: rustc 1.12.0 (3191fbae9 2016-09-23) cargo 0.13.0-nightly (109cb7c 2016-08-19) Code: extern crate num_bigint; extern crate num_traits; use num_bigint::{BigUint,…
mrLSD
  • 688
  • 1
  • 5
  • 14
18
votes
1 answer

AVX VMOVDQA slower than two SSE MOVDQA?

While I was working on my fast ADD loop (Speed up x64 assembler ADD loop), I was testing memory access with SSE and AVX instructions. To add I have to read two inputs and produce one output. So I wrote a dummy routine that reads two x64 values…
cxxl
  • 4,939
  • 3
  • 31
  • 52
18
votes
3 answers

Best bignum library to solve Project Euler problems in C++?

I am still a student, and I find project Euler very fun. sometimes the question requires calculations that are bigger than primitive types. I know you can implement it but I am too lazy to do this, So I tried few libraries, MAPM :: very good…
Khaled Alshaya
  • 94,250
  • 39
  • 176
  • 234
17
votes
3 answers

Fast bignum square computation

To speed up my bignum divisons I need to speed up operation y = x^2 for bigints which are represented as dynamic arrays of unsigned DWORDs. To be clear: DWORD x[n+1] = { LSW, ......, MSW }; where n+1 is number of used DWORDs so value of number x =…
Spektre
  • 49,595
  • 11
  • 110
  • 380
1
2 3
24 25