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

awk --bignum messes with floating point computations

Example input 42 -0.400000000000000022 I want to add 9'000'000'000'000'000'000 to the 1st column, and add 30 to the 2nd column. $ echo 42 -0.400000000000000022 | awk '{ $1 += 9000000000000000000; $2 += 30 } { print }' 9000000000000000000…
Unda
  • 1,827
  • 3
  • 23
  • 35
0
votes
0 answers

How can I fix cannot convert number with >15 digits to a bigNumber while calculating pi?

The code is: const c = mult(426880, sqrt(10005)) let calc = bn(0); for (let k = 0; k < 20; k++) { const m = div(fac(mult(bn(6), k)), mult(fac(mult(bn(3), k)), pow(fac(k), bn(3)))) const l = add(mult(bn(545140134), k), bn(13591409)) …
0
votes
1 answer

How prolog is capable to perform large computational operations recursively so fast? like 10000 factorial

Why prolog is so fast and accurate in numerical computation like this one factorial(X, N) :- N = 0, X is 1; N > 0, N1 is N - 1, factorial(X1, N1), X is X1 * N. I entered factorial(X, 10000). and the answer was so accurate and…
0
votes
2 answers

How to Use BigNum Roblox Lua

I am trying to use BigNum in roblox lua so I can go past the max number for int values in roblox, however I can't figure out it works. The library is not very descriptive or informative:https://rostrap.github.io/Libraries/Math/BigNum/ I have…
0
votes
1 answer

What is the problem with my add big number code?

I searched everything I tried, but I couldn't find an answer I need. I was solving a problem called "Big Number A+B", with C language. The maximum value of A and B is 10^10000 so I couldn't solve it with unsigned long long, so I tried using char…
0
votes
0 answers

Bignum arithmetic: assembly optimization in Visual C++?

I have an existing project which uses its own Bignum C++ class, coding values internally as 512-bit integers using 8 32-bit limbs. (fixed-precision, not arbitrary). I'm trying to optimize adds (to start) using assembly. My two questions…
Endymio
  • 35
  • 6
0
votes
1 answer

(bignumber.js) "decimalPlaces" or "dp" not working

I'm creating a idle html5/js game where I use bignumber.js library to be able to store arbitrarly long numbers, as I requirement for a idle game. The problem is that when in the configuration I have the EXPONENTIAL_AT option setted to some number,…
ghsoares
  • 53
  • 2
  • 7
0
votes
0 answers

How to use mpi_read_binary() function?

I'm trying to do an RSA public key computation using the Polarssl RSA library. I get the source code of the library from here. I'm having issues while trying to use a function name mpi_read_binay(), defined in here. I'm not familiar with mpi…
perplex
  • 119
  • 2
  • 8
0
votes
3 answers

Python 3 decimal module calculation reversability

I am trying to implement a reversible physics engine so I have decided to use the decimal module. So this obviously works. >>> from decimal import * >>> a = Decimal('1') >>> b = Decimal('0.82') >>> a = a*b/b >>> print(a) 1 However, when this…
mlg556
  • 419
  • 3
  • 13
0
votes
1 answer

Why does the BN_bn2bin and BN_bin2bn not give me the same result if applied to an RSA key?

I m trying to create an RSA key (has type BIGNUM) and then turn it into a char* in order to send it over a client-server channel and then turn it again into a BIGNUM again. The problem is, when I do the double cast I do not get the original result.…
0
votes
0 answers

How do I implement the Words associated type for the BinaryInteger protocol?

I am trying to make a BigNumber library for Swift, that represents numbers with an array of UInt64's. I am trying to conform my UBigNumber struct to BinaryInteger, which means I must have the associated type Words. I implement it like this: ///…
Sylvan M.
  • 160
  • 7
0
votes
1 answer

Convert BIGNUM into raw binary file

I want to convert this hex string into raw binary file using BIGNUM's BN_bn2bin function BN_hex2bn(&asn1hash, "3031300D060960864801650304020105000420BC5F9353CBB9DCAE86B9F8F68C1C95856DB836ACA2E00C9319716CDF4DD0F5BA"); char *buf = (unsigned…
Deus Ex
  • 117
  • 1
  • 8
0
votes
1 answer

SyntaxError: identifier starts immediately after numeric literal while trying to create a BigInt in javascript

I am trying to solve Pi till n number of digits in JavaScript with this formula: #!/usr/bin/env js60 function calculatePi(n) { var q = t = k = 1 var m = x = 3 var n = n + 1 var r = 0 str = '' while (str.length < n) { …
15 Volts
  • 1,946
  • 15
  • 37
0
votes
1 answer

Is there a function that returns the number of characters in BigNumber.js?

I know about decimalPlaces: const number = new BigNumber(100.5254); number.decimalPlaces(); // 4 And precision: const number = new BigNumber(100.5254); number.precision(); // 7 But I couldn't find any function that returns only the number of…
Paul Razvan Berg
  • 16,949
  • 9
  • 76
  • 114
0
votes
1 answer

How to convert abitrary raw data into integer using C and GMP_Bignum

I am writing a program with GNU Bignum and what i want to do is simply read a binary file, and use the raw data as a Bignum integer, But whenever i read this file even though it is about 2MB long and try to print the number it gives me a very small…