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

Using perl bigint in ranges

When I iterate through some integer range and try to use $_ value as bigint, it behaves like regular number instead. So, the following code prints 100000000000000000000 1e+20 when I expect to see 100000000000000000000 100000000000000000000. use…
Ivan Smirnov
  • 4,365
  • 19
  • 30
0
votes
4 answers

How can I use BigInt class in vb.net? (visual studio 2008)

recently i use int64. but it's no more handle my data. so I want something like BigInt. any idea?
marocchino
  • 1
  • 1
  • 1
0
votes
2 answers

BigInt operator+ function?

I've been trying to work on the operator+ function but it doesn't seem to work.. Not sure what is wrong :s BigInt.h #include using namespace std; using std::cout; #ifndef BIGINT_H #define BIGINT_H class BigInt { //input and output…
Tong Zhang
  • 23
  • 1
  • 7
0
votes
3 answers

c# conversion bigint decimal

I'm working on a c# application with a sql server 2005 database. what is the best way to convert to decimal a value brought to a datareader from a database, not knowing if the value that is coming from the base is a decimal or is a bigint ? …
martin.softpro
  • 435
  • 6
  • 21
0
votes
1 answer

Create a table with a primary key and a separate unique column in SQL Azure Federation

How could I create a uniqueidentifier ID column and a unique nvarchar(256) email address column in SQL Azure Federation? I'm not a SQL guy, so I don't know how to set a unique constraint or if it's possible to do that in a federated database.…
Mark13426
  • 2,569
  • 6
  • 41
  • 75
0
votes
2 answers

SHA1 hexdigest to long

I have this Python Code (hexdigest is a SHA1): d = long(hexdigest, 16) if d >> 159: return "-%x" % ((-d) & (2**160-1)) return "%x" % d and I need this code translated into D. I tried several things: to!long(hexdigest, 16) – failed with…
dav1d
  • 5,917
  • 1
  • 33
  • 52
0
votes
1 answer

Change primary key type from int to bigint

I have some tables in my database that have primary keys of type int that I'd like to change to type bigint. What's the best strategy to accomplish this without dropping/recreating tables and constraints? These primary keys are being used as…
Adam Levitt
  • 10,316
  • 26
  • 84
  • 145
0
votes
1 answer

Nodejs bigint install

I am trying to install bigint: https://github.com/substack/node-bigint but I am not able due to the following errors: The npm-debug.log file contains: info it worked if it ends with ok verbose cli [ 'C:\\Program Files\\nodejs\\\\node.exe', verbose…
PazoozaTest Pazman
  • 749
  • 12
  • 33
0
votes
1 answer

MySql - bigints, php and auto string/int casting flip-flopping

I asked a question about bigints yesterday which was kindly answered. However, I have been observing some weird behaviour and would like to understand what is going on. In my php I have an array which I send back to a javascript web client program…
Rewind
  • 2,554
  • 3
  • 30
  • 56
-1
votes
1 answer

rust-gmp-kzen gmp bind problem : "dyld[...]: missing symbol called"

I am using rust-gmp-kzen library which bind rust to gmp. When I run the rust program, it aborts at the statement "BigInt::one();" which calls "__gmpz_init_set_ui" in it. I reinstall gcc, gmp, rustup vs. however problem still occurs. dyld[77446]:…
-1
votes
1 answer

not exact result of sum in python 3

I make functions of sum from 1 to last number as follows def sum_way1(last_num): sum_val = 0 for num in range(1, last_num+1): sum_val=sum_val+num return sum_val def sum_way2(last_num): return…
-1
votes
1 answer

What is the difference between 'bigint' (lowercase) and 'BigInt'?

So I am trying to update some typescript code that uses external library for big numbers to BigInt (ES2020) and linter is complaining a lot. I don't really understand what is going on here. It looks like there are two different types - 'bigint' and…
Hufsa
  • 19
  • 2
-1
votes
1 answer

From BigInt to HexString in littleEndian in SQL script

I have the following code in Sql Server 2019. declare @Id bigint declare @HexId varchar(50) set @Id = 98360090175733911 set @HexId = CONVERT(VARCHAR(50),CONVERT(VARBINARY(16),@Id),2) select @HexId This is working, but the result must be in…
-1
votes
1 answer

CAST Function using BIGINT

Unable to run the below code. Select Month(ROW_DATE) as Month, cast(sum(da.ASSISTS) as bigint)/cast(nullif(sum(da.acdcalls),0) as bigint) as [Assist%] FROM [D998AA0_TELECOM].[APD_TEL].[TCMS_DAGENT] da JOIN…
-1
votes
1 answer

Athena doesn't show column create as BIGINT

We tried to upload a csv file with column 'cpf' on AWS-Athena, the field cpf contains numbers like this '372.088.989-03' create external table ( cpf bigint, name string cell bigint ) Athena doesn't read this field, how can i…