futureproof Posted May 16, 2011 Share Posted May 16, 2011 I have a function that converts me from any base to base 10 but the result is very long and it cannot be stored in an integer. Can someone explain me how should i use bignum lib so i can print result? Link to comment
kao Posted May 16, 2011 Share Posted May 16, 2011 (edited) Depends on which bignum library you use. For example OpenSSL BigNum lib has functions: char *BN_bn2hex(const BIGNUM *a); char *BN_bn2dec(const BIGNUM *a);BN_bn2hex() and BN_bn2dec() return printable strings containing the hexadecimal and decimal encoding of a respectively. For negative numbers, the string is prefaced with a leading '-'. The string must be freed later using OPENSSL_free().EDIT: fixed formatting. Edited May 16, 2011 by kao Link to comment
futureproof Posted May 16, 2011 Author Share Posted May 16, 2011 http://gmplib.org/I am going to use this library. How should i do it? Link to comment
kao Posted May 16, 2011 Share Posted May 16, 2011 You really don't want to search, do you?/>http://gmplib.org/manual/Formatted-Output.html 1 Link to comment
Killboy Posted May 16, 2011 Share Posted May 16, 2011 (edited) ISO-C and most C++ compilers support 64bit integer (long long) and their unsigned equivalents. Maybe that's enough for your needs.unsigned long long ul64 = 1111111122222222ULL; Edited May 16, 2011 by Killboy Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now