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

JavaScript increment and decrement BigInt value in input type number max

I have HTML code: So, when I paste bigint into this input and try to increment or decrement, input value becomes in scientific notation format. I need to remove scientific notation format and get incremented or decremented…
Azizxon Zufarov
  • 107
  • 1
  • 3
  • 8
-1
votes
1 answer

How convert int to BigInteger (Python)

How do I convert int to BigInteger in Python? I can't find anything like this on the net for python. I need to convert int to BigInteger in order to compare via Sqlalchemy ORM with the value in the database (telegram_id are registered via models…
-1
votes
3 answers

Explicit conversion of bigint to date

I'm fixing an existing code but got stuck with it because SQL server keeps showing an error related to converting string to date and then bigint to date. so not sure which technique to use: below is my…
Soben_SPDEV
  • 37
  • 1
  • 7
-1
votes
1 answer

How to implement unsigned right shift for BigInt in JavaScript?

I tried this sort of implementation, but it doesn't appear to be working. function urs32(n, amount) { const mask = (1 << (32 - amount)) - 1 return (n >> amount) & mask } function flip32(n) { const mask = (1 << 32) - 1 return ~n &…
Lance
  • 75,200
  • 93
  • 289
  • 503
-1
votes
1 answer

How to split JavaScript BigInt into 5-bit chunks?

Building off of this question How to get this PRNG to generate numbers within the range? , I am making it support BigInt (big values) in JavaScript, and I think I have it right (please correct me if I did it incorrectly): const fetch = (x, o) => { …
Lance
  • 75,200
  • 93
  • 289
  • 503
-1
votes
1 answer

string to bigint in dart

I want to encrypt the String “this is a simple string” by modPow, but I don't find the method in BigInt API, How can I convert String to BigInt in Dart? String original = "this is a simple string"; BigInt modulusInt = BigInt.parse(n, radix:…
shaoml
  • 1
-1
votes
2 answers

How to store a very big number in C

So im fairly new to C but im trying to store a very very very large number. i couldnt tell you the exact number because it depends on the users input. But im trying to find a way to store something in a way that java or python does by using…
NotAidan
  • 11
  • 3
-1
votes
3 answers

Sqlite integer overflow while using BIGINT

Having a sqlite3 I would like to query and sum different values. The query I'm trying to do is: SUM(CAST(amountA AS BIGINT)) as totalA, SUM(CAST(amountB AS BIGINT)) as totalB When the query finds several results it will trigger: error="integer…
manolodewiner
  • 504
  • 3
  • 26
-1
votes
1 answer

C++ multiplying BigInt - Exception thrown at 0x00007FFD777FF530 (ucrtbased.dll)

I am currently trying to use this BitInt library for c++14 to perform larger calculations. https://faheel.github.io/BigInt/ Every time two BitInts are multiplied an error appears. I reinstalled Visual Studio and the underlying compiler and I am…
-1
votes
2 answers

Truncate with zeros and round BigInt

I have a BigInt 123456789n. I want to truncate it with two zeros to 123456700n. But I don't think that is good enough - I want the last remaining digit to be rounded by the last truncated number. So the result should be 123456800n. Examples: 1100n…
Sámal Rasmussen
  • 2,887
  • 35
  • 36
-1
votes
1 answer

Program in Dart OK with int but unresolved with BigInt

Hi, I have wrote a program that solve a Puzzle in Python. To progress in Dart, I have tried to write in this langage but unfortunately, I did not solve there: Link of the puzzle: https://www.codingame.com/training/easy/happy-numbers My code that It…
Gromph
  • 123
  • 12
-1
votes
1 answer

How to use JavaScript to handle complex 100 digits (+/-) times 100 digits (+/-) multiplication without having an overflow error?

When I tried BigInt, the result returned a wrong result: BigInt(123456789123456789*111111111111) 13717421013703702653171662848n And this is what the actual result should be like by hand-written calculation: 13717421013703703578986282579 Is there a…
Tony Tsui
  • 21
  • 3
-1
votes
1 answer

BigInt pointer in Go

I was playing around with various packages and data types and I came across this function(big.NewInt()) from "math/big" package. so this function returns a pointer to the type bigInt but when i print it out i get the actual value not the address…
Chandru
  • 467
  • 1
  • 8
  • 17
-1
votes
2 answers

How to convert MySQL's BIGINT into unsigned without losing data?

I need to convert MySQL database tables column from (signed) BIGINT into unsigned BIGINT. If I do: ALTER TABLE `$tblNm` MODIFY `flgs` BIGINT UNSIGNED; Any values that have 63-bit set are reset to 0! What do I need to do so that all values are…
c00000fd
  • 20,994
  • 29
  • 177
  • 400
-1
votes
2 answers

Convert Bigint to Datetime SQL Server

I have a table that has a field Report_Date. This field is a bigint type. I have another table that has ReportDate that is datetime type. I want to combine data from each table, but I want the bigint converted into a datetime. I tried SELECT…
user7577070
  • 97
  • 3
  • 9