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
15
votes
1 answer

OpenSSL BN_CTX usage

From here I understand that BN_CTX is a structure that holds BIGNUM temporary variables. When will those BIGNUM variables enter BN_CTX's BN_POOL? If I have a bignum_ctx BN_CTX *ctx (either declared at the top of my function, or passed in as an…
Chiara Hsieh
  • 3,273
  • 23
  • 32
14
votes
3 answers

Large numbers in Pascal (Delphi)

Can I work with large numbers (more than 10^400) with built-in method in Delphi?
regexp
  • 263
  • 2
  • 8
13
votes
1 answer

What is the best way to check for infinity in a Perl module?

In one of my modules, I have to deal with the concept of infinity. To date, I have been using 9**9**9 as positive infinity, and this seems to work well, is fast, and seems to be what perl's internals use as infinity. However, things get a bit…
Eric Strom
  • 39,821
  • 2
  • 80
  • 152
12
votes
1 answer

custom data type in C

I am working with cryptography and need to use some really large numbers. I am also using the new Intel instruction for carryless multiplication that requires m128i data type which is done by loading it with a function that takes in floating point…
projection
  • 141
  • 1
  • 2
  • 5
12
votes
6 answers

How to Code a Solution To Deal With Large Numbers?

I'm doing some Project Euler problems and most of the time, the computations involve large numbers beyond int, float, double etc. Firstly, I know that I should be looking for more efficient ways of calculation so as to avoid the large number…
r0ach
  • 511
  • 3
  • 6
  • 14
12
votes
2 answers

bignum in emacs/elisp

Does emacs have support for big numbers that don't fit in integers? If it does, how do I use them?
Tal Pressman
  • 7,199
  • 2
  • 30
  • 33
11
votes
1 answer

How does GMP stores its integers, on an arbitrary number of bytes?

2^64 is still far from the "infinity" my ram/hard drive can handle... First I wonder how GMP works with memory/processor since it does some kind of shady optimisations... I was also wondering if there is a way of storing an integer (unsigned, it's…
gokoon
  • 1,017
  • 3
  • 11
  • 14
11
votes
3 answers

Error: Reference to undefined global `Num'

I'm trying to use the Num module in OCaml (bignums and big fractions). Some things seem to be working, while others seem not to, and I'm not able to generate a single, complete example. For instance: # Num.Int(234);; - : Num.num = Num.Int 234 #…
Mayer Goldberg
  • 1,378
  • 11
  • 23
11
votes
2 answers

C++ compile-time bignum library

Is there any compile-time library (template metaprogramming) for arbitrary-precision arithmetic in C++? I need this to help with fixed-point arithmetic and binary scaling in my program for AVR microcontrollers. For example, when two numbers each…
11
votes
3 answers

Speed up x64 assembler ADD loop

I'm working on arithmetic for multiplication of very long integers (some 100,000 decimal digits). As part of my library I to add two long numbers. Profiling shows that my code runs up to 25% of it's time in the add() and sub() routines, so it's…
cxxl
  • 4,939
  • 3
  • 31
  • 52
10
votes
2 answers

How do you downgrade a bigrat?

perl -Mbigrat -E'for (1..100) { $i += 1/3; say int($i), "\t", sprintf "%.55f", $i }' spams a lot of warnings: Argument "100/3" isn't numeric in addition (+) at …/site_perl/5.24.1/Math/BigRat.pm line 1939. Run again without -Mbigrat to see the…
daxim
  • 39,270
  • 4
  • 65
  • 132
9
votes
2 answers

Efficient Multiply/Divide of two 128-bit Integers on x86 (no 64-bit)

Compiler: MinGW/GCC Issues: No GPL/LGPL code allowed (GMP or any bignum library for that matter, is overkill for this problem, as I already have the class implemented). I have constructed my own 128-bit fixed-size big integer class (intended for use…
Simion32
  • 141
  • 1
  • 2
  • 9
9
votes
1 answer

Combined multiply divide operation on 64bit signed integer without overflow

I need to calculate result = (dividend * factor) / divisor where dividend: full range of int64_t values factor: either a full range of uint32_t values or as a special case 2^32 divisor: positive values of int64_t result: is guaranteed to fit in a…
p.g.
  • 315
  • 1
  • 10
9
votes
2 answers

How to serialize the GMP mpf type?

It seems that GMP provides only string serialization of the mpf (floating point) type: mpf_get_str(), mpf_class::get_str() The mpz (integer) type has an additional interface for raw bytes:…
jrr
  • 1,877
  • 19
  • 29
9
votes
3 answers

How to add 2 arbitrarily sized integers in C++?

I would like to add 2 arbitrarily sized integers in C++. How can I go about doing this?
BUKA
  • 91
  • 1
  • 2
1
2
3
24 25