Questions tagged [bigint]

Arbitrary-precision arithmetic (also called bignum arithmetic, multiple precision arithmetic, or infinite-precision arithmetic) indicates that calculations are performed on numbers which digits of precision are limited only by the available memory of the host system. This contrasts with the faster fixed-precision arithmetic found in most arithmetic logic unit (ALU) hardware, which typically offers between 8 and 64 bits of precision.

Several modern programming languages have built-in support for bignums, and others have libraries available for arbitrary-precision integer and floating-point math. Rather than store values as a fixed number of binary bits related to the size of the processor register, these implementations typically use variable-length arrays of digits.

, , and , supports arbitrary precision integers (also known as infinite precision integers or bignums). Other languages which do not support this concept as a top-level construct may have libraries available to represent very large numbers using arrays of smaller variables, such as and class or "bigint" package.

These use as much of the computer's memory as is necessary to store the numbers; however, a computer has only a finite amount of storage, so they too can only represent a finite subset of the mathematical integers. These schemes support very large numbers, for example one kilobyte of memory could be used to store numbers up to 2466 decimal digits long.

Application

A common application is public-key cryptography (such as that in every modern Web browser), whose algorithms commonly employ arithmetic with integers having hundreds of digits. Another is in situations where artificial limits and overflows would be inappropriate. It is also useful for checking the results of fixed-precision calculations, and for determining the optimum value for coefficients needed in formulae, for example the √⅓ that appears in Gaussian integration.

Big ints can also be used to compute fundamental mathematical constants such as π to millions or more generally to investigate the precise behaviour of functions such as the Riemann zeta function where certain questions are difficult to explore via analytical methods. Another example is in rendering fractal images with an extremely high magnification.

Arbitrary-precision arithmetic can also be used to avoid overflow, which is an inherent limitation of fixed-precision arithmetic. Some processors can instead deal with overflow by saturation, which means that if a result would be unrepresentable, it is replaced with the nearest representable value.

718 questions
-1
votes
1 answer

How to deal with 128bit variable in MinGM32 bit compiler for Encryption (Diffie Hellman Algorithm) in Qt

I want to use the below equation in one of the code A = g^a mod p; //g raise to a modulus p. (something like 2^5 % 3) = 32%3 = 2 (This equation looks like Diffie Hellman algorithm for security) Where: ^ is (power) g is fixed number 0x05 a is…
-1
votes
1 answer

Array with addresses

I have a problem with my code. I tried to implement big integers (bigger than the normal) and all went fine. I chose to represent them as dynamic arrays. So, the function receives a pointer for shorts (to use less memory; I could use char that uses…
DMaxter
  • 178
  • 5
  • 19
-1
votes
2 answers

Why i can't use equals for BigInteger and int?

When i try to compare BigInteger and int: BigInteger balance = new BigInteger(out_str.substring(186, 201).trim()); if (!balance.equals(0)) {...} I get: equals () between objects of inconvertible types 'int' and 'BigInteger'
bardir16
  • 13
  • 5
-1
votes
1 answer

Converting a MSSQL Datestamp to BIGINT for UNIX

I've been having trouble with something i cannot quite get my head around and I was wondering if you can help? On my table, i have a column called ADDEDDATE This column shows the date in which an incident or ticket was added to the database table…
-1
votes
2 answers

Java count up/down in hexadecimal

I know you can just use an integer and count up and down then convert to a hexadecimal string, but I need to use integers larger than the max value (up to 0xffffffffffffffffffff or 1208925819614629174706175). What would be the most efficient way to…
G Smith
  • 53
  • 1
  • 9
-1
votes
1 answer

Golang: odd big Int behavior

So I am new to Go and fairly inexperienced with programming in general so I hope I don't get downvoted again for asking stupid questions. I am working my way through the project euler problems and at problem 25 "1000-digit Fibonacci number" I…
-1
votes
1 answer

Convert a long String to to a big int in javascript

im doing some stuff in javaScript and therefore need to convert a Text String to Decimal . The php code that i used was: function to_number($data) { $base = "256"; $radix = "1"; $result = "0"; for($i = strlen($data) - 1; $i >= 0; $i--) { …
dudu
  • 19
  • 4
-1
votes
1 answer

How did I store a BIGINT number in a 32-bit OS

I am running a LAMP stack on a raspberry pi 3 (64-bit SoC) with 32-bit PIXEL OS (a Raspbian version). I created a new table in MySQL and I set the Primary Key as unsigned BIGINT(20). Initially I thought that the database will just truncate the…
-1
votes
1 answer

Multiplying big numbers

The problem is to multiply big numbers. I am using a base of 10^9, and get problems when the numbers get to tenth of that. In the example below, I use a much smaller base for simplicity. #include #include using namespace…
Keltar Helviett
  • 638
  • 1
  • 7
  • 13
-1
votes
1 answer

SQL Bigint*Decimal

This may seem very simple but I can't figure it out. I have a field that is datatype bigint and I'm trying to multiply it by another field that is decimal(9,5) but I just get null in all of my calculations. I've tried casting the Bigint as decimal…
Michael Tsu
  • 49
  • 1
  • 10
-1
votes
1 answer

Destructor deleting memory premature

I am quiet new to memory management in C++. I made a BigInt class that is now fully implemented except for the destructor which is impacting performance of the program. However, when I try to implement the destructor my program crashes. In the…
sanic
  • 2,065
  • 4
  • 20
  • 33
-1
votes
2 answers

Perl and Big Number

For calculating nCr [ i.e. n ! / ( r ! * ( n-r )! ) ], written the below code. Perl code: ($i,$j)=(1000,100); print fact($i)/(fact($j)*(fact($i-$j))); sub fact{ return 1 if $_[0]<=1; return $_[0]*fact($_[0]-1); } which is giving output as…
karsas
  • 1,231
  • 4
  • 12
  • 24
-1
votes
2 answers

big num multiplication c++

So here I have two classes, on Safearray and one bigint calculator( the SafeArray is imperfect but it serves its purpose) what I really need help with is my multiply algorithm, when I compile nothing happens, I think the algorithm is mostly right(if…
jack
  • 19
  • 1
  • 6
-1
votes
1 answer

save array of bigint to file

I have a large array of big integers which I need to save to the disk for the next user session. I don't have a data base or the option to use one. Will large numbers take more space in memory when I write them to a text file? What is the best way…
Geremy
  • 19
  • 2
-1
votes
3 answers

Adding 32-bit numbers on a 32 machine, widening to a 64-bit sum in two registers

How to add couple of 32 bit numbers on a 32 bit machine but without precision loss, i.e. in a 64 bit "pseudo register" eax:edx. Using Intel syntax assembler.
Cartesius00
  • 23,584
  • 43
  • 124
  • 195
1 2 3
47
48