bignum

Adding floats with gmp gives “correct” results, sort of

In the code below I use mpf_add to add the string representation of two floating values. What I don't understand at this point is why 2.2 + 3.2 = 5.39999999999999999999999999999999999999 . I would have thought that gmp was smart enough to give 5.4 . What am I not comprehending about how gmp does...

Rails: Storing a 256 bit checksum as binary in database

I'm trying to store a SHA-2 256 bit checksum in a column: create_table :checksums do |t| t.binary :value, :null => false, :limit => 32 end I'm storing in the value like so: c = Checksum.new big_num = Digest::SHA2.new.update("some string to be checksum'd").hexdigest.to_i(16) c.value = big_num On the...

What is a convenient base for a bignum library & primality testing algorithm?

I am to program the Solovay-Strassen primality test presented in the original paper on RSA. Additionally I will need to write a small bignum library, and so when searching for a convenient representation for bignum I came across this specification : struct { int sign; int size; int *tab; } bignum; I...

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

Ok, so I am working with a PIC microprocessor, in C. It's a 16F, so it can't hold integers larger than 32bits (unsigned int32 is the largest datasize available) From a reader, I receive a 5 byte ID code. To transmit it, I have to encoded to BCD, digit by digit. I can't sprint it to a string, as it...

Why does division become faster with very large numbers

I wanted to see how constant the division operation is, so I ran this code import time def di(n): n/101 i = 10 while i < 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000: start = time.clock() di(i) end = time.clock() print("On " + str(i) + " " + str(end...

Accessing the highest digits of large numbers from Python long

I'm working with numbers with tens of thousands of digits in python. The long type works beautifully in performing math on these numbers, however I'm unable to access the highest digits of these numbers in a sufficiently fast way. Note that I don't know exactly how many digits the number contains....

Openssl, Invalid arguments &#39; Candidates are: int BN_set_word(bignum_st *, ?) &#39;

I am using OpenSSL for a cuda project. I just imported all the project from win to linux (Eclipse) I solved all the dependencies except this annoying error: Invalid arguments ' Candidates are: int BN_set_word(bignum_st *, ?) ' for this line: BN_set_word(two, 2); and the function itself says in the...