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
2 answers

Different 32bit-cast into long/__int64, why?

I'm writing my own small multiprecision library, and while writing the method for subtraction, I encountered some weird error. Here is the code block I wrote for for multiprecision subtraction: /* subtraction */ for (; p_aReverseIter !=…
user190502
0
votes
1 answer

Compare two big variables in javascript

I have 2 big variables, and I need to compare like: var a = 15000000000000000000000001 // integer var b = "15000000000000000000000000" // string In all my test comparisons get wrong results. eg: Convert var b into a integer var a =…
0
votes
1 answer

Binary GCD - too slow algorithm

According to Wikipedia (http://en.wikipedia.org/wiki/Binary_GCD_algorithm) I was trying to write binary GCD for bignums (up to 5000 digits). My GCD itself looks like this: bitset gcd(bitset u, bitset v) { bitset one (string("1")); …
Mateusz Kowalski
  • 205
  • 3
  • 10
0
votes
1 answer

C++ Bignums from file

I'm attempting to read two bignums and an operator from a file into integer vectors (in order to do math on them) and I'm not allowed to use C++ strings. The file is in the format: 2308957235.... add 234989234786.... I'm not very familiar with the…
Farlo
  • 17
  • 7
0
votes
1 answer

.Net public key file (.pke) to OpenSSL PEM

We are trying to read in a public key file into our Delphi application so that we can use it for encrypting some data using OpenSSL. We are stuck at trying to populate the pRSA structure in libeay32.pas. Basically we have read the modulus and…
There is no spoon
  • 1,775
  • 2
  • 22
  • 53
0
votes
1 answer

Convert a Series of Decimal Digits into a Hexadecimal Big Number in MASM

I'm writing a bunch of macros to deal with big numbers in MASM, and I have found myself needing to convert from a series of digits to a number. Basically, to get around MASM size restrictions, I've been passing bignums as strings. So, a bignum…
Rose Kunkel
  • 3,102
  • 2
  • 27
  • 53
0
votes
3 answers

Convert Decimal to Hex when no datatype can hold the full number

This is an almost exact duplicate of my own question a few weeks ago. Convert Hex to Decimal when no datatype can hold the full number This time, it is the reverse. I have the number (in a handy null terminated string) and I need the bytes that make…
Manuel Ferreria
  • 1,216
  • 1
  • 13
  • 23
0
votes
1 answer

Finding additive inverse using OpenSSL BIGNUM

I need to calculate the additive inverse of a large (BIGNUM) prime in C. So, basically, i need to multiply by -1. Is there an easy way to do this that i've missed? I don't see any functions in the documentation. All i've come up with is this,…
Chris C
  • 259
  • 2
  • 15
0
votes
3 answers

Calculating large power of a number

#include #include #define M 1000000007 using namespace std; long long int power(int a,int b) { if(b==0) return 1; else if(b==1) return a; else if(b%2==0) return power((a*a)%M,b/2); else …
LAP
  • 122
  • 1
  • 4
  • 14
0
votes
2 answers

String to BigNumber conversion, a particular solution

I'm writing a Java program to process electronic tax forms that come in some pseudo-xml format. The resulting amount of tax to be paid or refunded comes in the following format: 13-char long String of unsigned integers where the last two represent…
danirod
  • 1,011
  • 3
  • 9
  • 18
0
votes
1 answer

Bignum division with an unsigned 8 bit integer. C

I've created an algorithm for dividing a integer up to 255 bytes in size by an 8 bit integer and it works with the tests I've done. Does anyone have any comments for it or any improvement suggestions? Is there a better algorithm for this purpose? I…
Matthew Mitchell
  • 5,293
  • 14
  • 70
  • 122
-1
votes
2 answers

Represent big numbers with fewer characters (numbers)

I want to reduce the number of characters used to represent a very big number. For example. Take this number 4593638492...3837292 (1000+ characters long) What techniques or tricks can I use to represent this number using fewer characters (say around…
dickson
  • 11
  • 3
-1
votes
1 answer

Is there any optimal way to implement N byte integer and it's arithmetic operations in c++?

I'm trying to think of some interesting, reusable way to implement big integers using passed amount of bytes or resizing themselves when needed. I have no idea how to make it optimal in any way tho. Are there any tricks I could use, or do I have to…
Crimsoon
  • 83
  • 8
-1
votes
1 answer

how to get uint256_t upper and lower part in nodejs/javascript,

i have equivalent c++ but not sure how to implement this in javascript/nodejs. c++: template enum { WIDTH = BITS / 32 }; uint32_t pn[WIDTH]; uint256 seed =…
hashgoal
  • 41
  • 1
  • 3
-1
votes
1 answer

BigNum snd stack overflow

What is the BigNum and how can we work with very big numbers,like “find the sum of the even-valued terms of fibonachi sequence that the value doesn’t exceed 4 million” that we cannot put it in long long int?