Trying to update the number conversion logic to work better in javascript using samples from raphaeljs and javasripter.net