问题
How to from a
JavaScript String, assuming that it will be converted to base 2 number representation, get length of it?
var a = "27253612834651292817068063108051952822914696443427141008555142123316682144932254071632833688593262045689493008241655341783955326980297437493219806268065150183246111733458990008880411449482143090406377611761078341580375284217607011541826787677233082585754389591236816422975207551625801435043443350389601614965";
npm packages jsbn dont have it and big-integer returns in science notation (2e+...)
I need to mimick C++ code result of mpz_sizeinbase(a, 2)
- gmplib.org/manual/Miscellaneous-Integer-Functions.html
回答1:
I've found library that does all I need in npm "big-integer"
- Parse string to biginteger https://github.com/peterolson/BigInteger.js#bigintnumber-base
- Parse biginteger to string converting it to other base https://github.com/peterolson/BigInteger.js#override-methods
来源:https://stackoverflow.com/questions/42915607/javascript-big-integer-from-string-to-base-2