I need to do the following in JavaScript and so far been unable to find solutions to do it seamlessly:
I think you need a big number library for JavaScript such as http://jsfromhell.com/classes/bignumber.