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

How can I set the level of precision for Perl's bignum?

I'm trying to use the bignum module in Perl and want to set the precision. I know this can be done via a one liner as detailed on the module's CPAN page: $ perl -Mbignum=p,-50 -le 'print sqrt(20)' ...which will print out the square root of 20 to…
theraccoonbear
  • 4,283
  • 3
  • 33
  • 41
8
votes
2 answers

SHA256 Hash results different across Android & iOS for Big numbers

I'm trying to Hash a BigInteger/BigNum and I'm getting different results in Android/iOS. I need to get the same Hash result so that both the apps work as per the SRP protocol. On closer inspection it is working fine for positive numbers but not…
AndroidDev
  • 5,193
  • 5
  • 37
  • 68
8
votes
6 answers

Fastest way to convert binary to decimal?

I've got four unsigned 32-bit integers representing an unsigned 128-bit integer, in little endian order: typedef struct { unsigned int part[4]; } bigint_t; I'd like to convert this number into its decimal string representation and output it to…
ianh
  • 836
  • 1
  • 5
  • 15
8
votes
6 answers

Finding prime factors to large numbers using specially-crafted CPUs

My understanding is that many public key cryptographic algorithms these days depend on large prime numbers to make up the keys, and it is the difficulty in factoring the product of two primes that makes the encryption hard to break. It is also my…
Adam Batkin
  • 51,711
  • 9
  • 123
  • 115
8
votes
5 answers

Exponentiation in Ruby 1.8.7 Returns Wrong Answers

I met this problem when I tried to compute 3**557 in irb. Ruby and MacRuby both are installed in my Mac (OS X 10.8). And the version of ruby is 1.8.7, of MacRuby 0.12 (ruby 1.9.2). rib and macirb gave me two different answers on computation of…
Vej
  • 390
  • 1
  • 7
  • 28
7
votes
3 answers

Square root of bignum using GMP

I need to get the square root of a 210 digit number accurately, I thought GMP was the right tool for the job, what am I doing wrong? #include #include #include "gmp.h" int main (int argc, char *argv[]) { mpz_t sq_me, sq_out,…
YHVH
  • 585
  • 4
  • 12
7
votes
1 answer

Why does RISC-V not have an instruction to calculate carry out?

I need to deal with bignum calculation (addition and subtraction, but I treat subtraction as equivalent to signed addition) on RISC-V and the situation is a bit complicated. What I gather from half an hour of internet research: RISC-V operations do…
piegames
  • 975
  • 12
  • 31
7
votes
2 answers

How to interpret javascript BN object?

While I was working on smart contract using truffle, whenever request some number like account balance or address from the truffle console; I receive a BN object which looks like this: BN { negative: 0, words: [ 37748736, 3305132, 2220446, <1…
jarvis1234d
  • 81
  • 1
  • 5
7
votes
8 answers

How does a 32-bit operating system perform the 2^56 modulo 7?

How does the system perform the 2^56 modulo 7, if it's 32 bits operating system in cryptography for example? And how it stored in memory?
regexp
  • 263
  • 2
  • 8
7
votes
3 answers

How to implement long division for enormous numbers (bignums)

I'm trying to implement long division for bignums. I can't use a library like GMP unfortunately due to the limitations of embedded programming. Besides, i want the intellectual exercise of learning how to implement it. So far i've got addition and…
Chris
  • 39,719
  • 45
  • 189
  • 235
7
votes
4 answers

How to implement c=m^e mod n for enormous numbers?

I'm trying to figure out how to implement RSA crypto from scratch (just for the intellectual exercise), and i'm stuck on this point: For encryption, c = me mod n Now, e is normally 65537. m and n are 1024-bit integers (eg 128-byte arrays). This is…
Chris
  • 39,719
  • 45
  • 189
  • 235
7
votes
1 answer

Convert a big number given as a string to an OpenSSL BIGNUM

I am trying to convert a string p_str representing a big integer to a BIGNUM p using the OpenSSL library. #include #include int main () { /* I shortened the integer */ unsigned char *p_str =…
perror
  • 7,071
  • 16
  • 58
  • 85
7
votes
2 answers

How are bignums represented internally?

Python provides a "bignum" type called "long" which can represent arbitrarily large numbers. What is the internal representation of this type? I ask in part because I am curious what operations might be particularly fast or slow on these numbers. …
nibot
  • 14,428
  • 8
  • 54
  • 58
6
votes
1 answer

What is the meaning of `c`, `e`, and `s` in bignumber.js?

What are the meanings of the c, e, and s fields in the object produced by bignumber.js? For example: > new BigNumber('1234') { c: [1234], e: 3, s: 1 } > new BigNumber('12345678901234567890') { c: [123456, 78901234567890], e: 19, s: 1 }
David Wolever
  • 148,955
  • 89
  • 346
  • 502
6
votes
4 answers

Generating a pseudo-natural phrase from a big integer in a reversible way

I have a large and "unique" integer (actually a SHA1 hash). Note: While I'm talking here about SHA1 hashes, this is not a cryptography / security question! I'm not trying to break SHA1. Imagine a random 160-bit integer instead of SHA1 if that will…
Alexander Gladysh
  • 39,865
  • 32
  • 103
  • 160
1 2
3
24 25