Your input loops have serious problem. Also you use i to count the length of both a and b, but you don't store the length of a. So if they type two numbers that are not equal length then you will get strange results. The losing of the first digit...
unsigned char *p_str = "82019154470699086128524248488673846867876336512717"; BIGNUM *p = BN_bin2bn(p_str, sizeof(p_str), NULL); Use int BN_dec2bn(BIGNUM **a, const char *str) instead. You would use BN_bin2bn when you have an array of bytes (and not a NULL terminated ASCII string). The man pages are located at BN_bin2bn(3). The correct code would look...
javascript,arrays,binary,bignum,int64
There is an implementation for converting hex string to Int64 (both signed and unsigned) here: LINK That code returns right result: javascript: new HexStringToInt64StringConverter(true).convert('a2921f66350ae040') // will return -6732283969128439744 same as BitConverter.ToInt64() in BCL ...
c++,math,fractions,bignum,arbitrary-precision
If you're using boost, you can use boost::rational in conjunction with boost::multiprecision::cpp_int (arbitrary-precision integer): #include <boost/rational.hpp> #include <boost/multiprecision/cpp_int.hpp> using boost::multiprecision::cpp_int; typedef boost::rational<cpp_int> fraction_t; For some reason, the constructor fraction_t("1", "2") doesn't work, although cpp_int("1") does, so if you need large int literals, you can use this helper function to not...
The error was at: BN_bin2bn((uchar*)"\x01\x02\**0x03**\0",3,p); BN_bin2bn((uchar*)"\x02\x03\**0x04**\0",3,B); BN_bin2bn((uchar*)"\x03\x04\**0x05**\0",3,a); It should be BN_bin2bn((uchar*)"\x01\x02\x03\0",3,p); BN_bin2bn((uchar*)"\x02\x03\x04\0",3,B); BN_bin2bn((uchar*)"\x03\x04\x05\0",3,a); ...
If the toplevel is already launched, you can dynamically load the library: # #load "nums.cma";; # Num.mult_num;; - : Num.num -> Num.num -> Num.num = <fun> Another possibility (which will work for all third party libraries and will manage paths and dependencies for you) is to use ocamlfind. For this,...