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.

Filter by
Sorted by
Tagged with
0 votes
0 answers
8 views

SQL SELECT ERRO ARITHMETIC

I want convert a datetime to milliseconds since 1970-01-01, but my conversion is overflow than integer in select. But SQL Server return error : Arithmetic overflow error converting numeric to data ...
Blixow's user avatar
  • 11
2 votes
1 answer
90 views

BigInt modulo float

I would like to calculate the a bigint modulo a number (float) As a % b will necessarily be lower than b, the result can be expressed as a number. example: with 10 000 000 000 000 000 004 modulo 1.43 ...
Yukulélé's user avatar
  • 15.9k
0 votes
3 answers
91 views

How to generate a random `bigint` number between two `bigint` numbers in TypeScript?

I have saw this but it does not provide an answer. I would want something like this: let randomBigInt = generateRandomBigInt(0, 920392947394829032030943); console.log(randomBigInt); // 4893848594594
Jim's user avatar
  • 536
0 votes
1 answer
96 views

How to store a uuid type into bigint effectively?

In my application in Python, I have a function that accepts (_id: uuid.UUID) which is 128-bit value. I need to store this value into postgres database as a advisory lock using pg_advisory_xact_lock ...
J. Donič's user avatar
  • 141
0 votes
1 answer
59 views

Is there a method to print a n-bit (like 256-bit) integer in c without using an external library?

I Have found a way to make a n-bit integer and do arithmetic on the integers, But I don't know how to print those integers, My method to make a n-bit integer is just to make an array of, lets say char'...
Behrad Sharifi's user avatar
2 votes
0 answers
58 views

Load Python Pandas data into SQL Server, conversion from variable or parameter type INT to target column type BIGINT is not supported

I am trying to load a Python Pandas dataset into an existing table in SQL Server database. In SQL Server, the table contains three columns and types are below: [account] [bigint] NULL, [info] [...
Steve Timb's user avatar
0 votes
1 answer
73 views

Multiplying float with BigInt in JavaScript? [duplicate]

By using this website I can calculate for example x = 0.28 y = 1e18 x * y = 280,000,000,000,000,000 How can I do this in javascript while x could be any number, including ints, and y could be any ...
user2640145's user avatar
-1 votes
1 answer
54 views

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 ...
Naim küçükdemirci's user avatar
0 votes
2 answers
129 views

Adding two byte arrays which represent unsigned numbers together fails to add last carry in c

I have been writing a big numbers library for practice reasons in C and the addition operation is causing me some issues. It works normally but ignores the carry at the end and the result is incorrect....
block103's user avatar
0 votes
1 answer
32 views

Javascript Type Error: Cannot mix BigInt and other types, use explicit conversions

I was trying to add a individual digits of an BigInt number to an array. When I did that I encountered the above error. Below is the code Snippet: var plusOne = function(digits) { const ...
Aravind Raghunath's user avatar
-1 votes
1 answer
67 views

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(...
user15632158's user avatar
0 votes
1 answer
257 views

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 ...
Hufsa's user avatar
  • 29
0 votes
0 answers
38 views

Chai js tests stop running when assert on 2 BigInts fails

I just had a strange case where my tests just stopped running when doing an assert.equal over 2 BigInts without converting them to strings. And This only happens if the 2 BigInts are not equal. The ...
Moumou's user avatar
  • 1,513
0 votes
1 answer
72 views

Multiply big numbers as a string question not using BitInt for codewars but like 4-6 random tests out of like 100 are missing 1 digit

I'm still learning JavaScript so the code is probably messy but this is my function so far. This function is supposed to multiply the shorter number with the larger number digit by digit, padStart ...
Dave Park's user avatar
7 votes
2 answers
465 views

AddressSanitizer: stack-buffer-overflow on boost cpp_int

I have the following code sample that should convert std::array<uint8_t> to BigInt i.e. boost::multiprecision::cpp_int. I compile this code with clang64 15.0.7 (С++17) from MSYS2. Code works ...
mblw's user avatar
  • 1,760
0 votes
0 answers
76 views

How can I make effective idle game numbers?

Numbers get so big they go negative. I'm trying to make an idle game in flutter, but my numbers get so big the go negative. I can't find anything anywhere that will raise the limit on int or num. I ...
Tester Lane's user avatar
3 votes
2 answers
76 views

Uniform random integer in a range using minimum random bits [duplicate]

I need to generate unbiased uniformly distributed integers in an arbitrarily large range, using random bits which can be expensive to obtain, therefore I want to use as few random bits as possible on ...
Pedro Gimeno's user avatar
  • 2,897
3 votes
1 answer
51 views

Limit to maximum value that can be read from a file as a hex value

I am using the following code to read from a file and write to another file: #!/usr/bin/perl use bigint qw/hex/; use strict; use warnings; my $defaultfile = 'C:/Users/john/Desktop/input.txt'; my $...
Tah_Ra's user avatar
  • 129
0 votes
2 answers
125 views

BigInt and Segmentation Fault

My program runs on all numbers, but not when calculating BigInt MAX(INT_MAX). When I try to run this, it gives me a segmentation fault. Here is the BigInt class: #include <iostream> #include <...
Stephen Martinez's user avatar
0 votes
1 answer
81 views

BigInt in node 12 (v12.22.12)

I'd like to use BigInt with node 12.22.12. It works fine in the REPL but in my script I need to "require" it. I tried things like const BigInt = require('BigInt') or require('node:bigint') ...
raphaelSeguin's user avatar
0 votes
1 answer
107 views

How to handle 64-bit signed integer coming from NextJS backend API

I have a NextJS application where one of the backend API routes returns a JSON object that contains a 64-bit signed integer. // userId is the 64-bit signed integer res.status(200).json({ id: userId, ...
dokgu's user avatar
  • 5,266
0 votes
0 answers
201 views

How to implement addition and multiplication for 256-bit unsigned integer using Intel's ADX intructions?

I need to do arithmetic operations on 256-bit unsigned integer and I need a fast implementation. AFAIK, SIMD instructions do not help because of carry propagation (Can long integer routines benefit ...
phqb's user avatar
  • 359
0 votes
0 answers
41 views

Incorrect results subtracting 1 from 100 working with a string of ASCII digits

section .bss num: resb 3 section .text global _start _start: ; Read input mov eax, 3 mov ebx, 0 mov ecx, num mov edx, 3 int 80h sub byte [num+2], 1 cmp byte [num+2], 255 jne ...
Ki Kim's user avatar
  • 1
1 vote
2 answers
68 views

Java CombinatoricsUtils.binomialCoefficient() arithmetic error due to large numbers

When I try to calculate the combination of large numbers, e.g. 334 choose 179, using the Java Apache Math3 CombinatoricsUtils.binomialCoefficient() method, I receive an Exception in thread "main&...
Thend's user avatar
  • 105
4 votes
1 answer
490 views

C++ Boost multiprecision integer uint256_t has sizeof bigger than 32 bytes

It is well known that built-in C++ types uint32_t, int32_t, uint64_t, int64_t and even GCC/CLang built-in types __int128 and unsigned __int128, all have sizeof exactly equal to bit-width divided by 8. ...
Arty's user avatar
  • 15.3k
3 votes
0 answers
365 views

TypeError: Cannot convert BigInt to number, js engine: hermes - noble-secp256k1 package

I have a react native app, I am trying to use the package noble-secp256k1. I need this in order to generate a key pair (private and public key) secp.getPublicKey(secp.utils.randomPrivateKey()), ...
VGabriel45's user avatar
0 votes
1 answer
190 views

How does BigInt.toString() work with very big BigInt?

As it specified in the BigInt spec: The value may be any size and is not limited to a particular bit-width As it specified in the String spec: The String type is the set of all ordered sequences of ...
EzioMercer's user avatar
  • 1,514
2 votes
1 answer
184 views

Algorithm to convert binary big integer to scientific notation with truncation to a 1-digit mantissa

I have a very big unsigned binary big integer in the scale of 6*10^120. Assume the big integer is stored in a struct of many QWORD (8 bytes) unsigned integers or several YMM registers. I want to ...
Danny Cohen's user avatar
0 votes
2 answers
376 views

Typescript bigint exceeds (non-specified) maximum; `RangeError: Maximum BigInt size exceeded`

For safe prime p, prime q = (p - 1)/2, and generator g = 2, we have a distinct sequence (mod p): g^0,g^1,...,g^q-1 Then the sequence repeats, g^q (mod p) = g^0 (mod p) The largest necessary bigint is ...
bs-'s user avatar
  • 1
0 votes
1 answer
176 views

Is there any way to return integer value from MySQL?

Is there any way to return integer value from mysql? Select CAST(1, int) is thowing error as this "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server ...
Ghanshyam Tarsariya's user avatar
0 votes
1 answer
77 views

Extract 2 digit from a BigInt of 8 digit in Hive

In my hive table I need to extract from column DATE(stored as bigint), 2 digits(month) in center. For Example: 20220120 -> 01 20211201 -> 12 Is it possible to do directly without casting column ...
Catanzaro's user avatar
  • 1,332
2 votes
1 answer
217 views

V8 (or other JS engine) BigInt Implementation - Displaying as Decimal

I'm wondering if someone might be able to explain a specific aspect of the JavaScript BigInt implementation to me. The overview implementation I understand - rather than operating in base 10, build an ...
JMA's user avatar
  • 365
0 votes
2 answers
99 views

How to divide by huge number

I am trying to do this: const numerator = 268435456; const denominator = 2 ** 64; const decimalFraction = numerator / denominator; To make this work, I have tried to use the code suggested here: ...
Daniel Porteous's user avatar
0 votes
2 answers
294 views

Rust BigInt memory allocation and performance compared to Python BigInt implementation

When working with num_bigint::BigInt I have run into some performance limitations, for context I am working on https://www.geeksforgeeks.org/how-to-generate-large-prime-numbers-for-rsa-algorithm/ [...
Poseidon's user avatar
  • 165
2 votes
3 answers
155 views

VBA calculate with numbers in range 10^40

I asked a similar question yesterday, but for smaller numbers. So today again :-) I am trying to calculate: A random number in the range 10^40 mod a random number in the range of 100. I saved the ...
Fabian Müller's user avatar
5 votes
1 answer
358 views

Is there a way to do a right bit-shift on a BigInt in Rust?

I get this error when attempting to do >> or >>= on a BigInt: no implementation for `BigInt >> BigInt using the num_bigint::BigInt library Edit: More Context: I am rewriting this ...
Poseidon's user avatar
  • 165
1 vote
1 answer
75 views

Programmatically solving Sam Loyd's Battle of Hastings puzzle - performance issues with BigInt

I'm having performance issues when trying to check whether integer n is a perfect square (sqrt is a whole number) when using BigInt. Using normal numbers below Number.MAX_SAFE_INTEGER gives reasonable ...
Edge's user avatar
  • 2,486
1 vote
1 answer
50 views

Could an ECMA-262-conformant JavaScript implementation have `2n` be the maximum BigInt size?

As far as I can tell, the ECMASCRIPT spec doesn't say what the minimum maximum size for a BigInt value is, it just says "arbitrary precision", which seems in this context to mean "...
Max Heiber's user avatar
  • 14.6k
0 votes
1 answer
273 views

converting from BigInt to BitArray

what would be best way to convert object using rust from bigint (BigInt) to bits (BitArray<217>) also in reverse (example below) using binary to decimal calculator I verified by hand that bigint ...
zkbitcoin.com's user avatar
6 votes
1 answer
371 views

Unsigned 64x64->128 bit integer multiply on 32-bit platforms

In the context of exploratory activity I have started to take a look at integer & fixed-point arithmetic building blocks for 32-bit platforms. My primary target would be ARM32 (specifically armv7),...
njuffa's user avatar
  • 24.3k
2 votes
1 answer
474 views

Converting big.Int to [2]int64, vice-versa and two's complement

I am trying to convert Go big.Int, which will represent a 128-bit integer to [2]int64. The idea is to be able to match Rust's i128::to_le_bytes(), which encodes 128-bit signed integer into little-...
plenio's user avatar
  • 23
0 votes
1 answer
295 views

How can I use arm adcs in loop?

In arm assembly language, the instruction ADCS will add with condition flags C and set condition flags. And the CMP instruction do the same things, so the condition flags will be recovered. How can I ...
xxxx's user avatar
  • 33
1 vote
0 answers
728 views

Handle BigInt numbers directly from a response without any loss

A 3rd party server is returning id's (large number) in int instead of string format, and my server being in Node JS accepts the incoming object that contains the id, and when I use it or print it, I ...
Ujjal Khadka's user avatar
-1 votes
1 answer
72 views

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 @...
B.Berrevoets's user avatar
0 votes
1 answer
98 views

Create copy of existing table with indexes, constraints and structure but without data

Problem statement : in a postgresql table I am getting an error as "Integer out of range" for the column 'id' type 'serial integer' RCA : As it is a serial integer column which already ...
Rohith Kumar's user avatar
-1 votes
1 answer
308 views

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].[...
Riddhi Solanki's user avatar
-1 votes
1 answer
178 views

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 ) ...
William Soares's user avatar
1 vote
1 answer
88 views

How to use 64 bit integers for Firestore in browsers?

Firestore can store 64 bit signed integers. However Javascript's number type has a 53 bit mantissa. How to read/write big numbers with Firestore without losing precision? I tried: Using BigInt: The ...
secretshardul's user avatar
0 votes
0 answers
182 views

Using snowflake bigint IDs with Laravel & VueJS

I'm using snowflake IDs which are bigInts for my Laravel API project, Vuejs/JS does not support the size of the IDs so requires them to be converted to strings. If I cast all my IDs in each model ...
Kris's user avatar
  • 1
0 votes
1 answer
68 views

How to find 15% from big.Int

I'm want to get 15% of big.Int value, how can I do this? new(big.Int).Mul(totalValue, new(big.Int).Div(new(big.Int).SetUint64(15), new(big.Int).SetUint64(100))) returns 0
femto's user avatar
  • 11

1
2 3 4 5
15