(function(j){for(var n=function(a){var c=false;if(a<0){c=true;a=-a}if(a<1){var b=parseInt(a.toString().split("e-")[1]);if(b){a*=Math.pow(10,b-1);a="0."+new Array(b).join("0")+a.toString().substring(2)}}else{var b=parseInt(a.toString().split("+")[1]);if(b>20){b-=20;a/=Math.pow(10,b);a+=new Array(b+1).join("0")}}return c?"-"+a:a},f={zero:0,one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12,thirteen:13,fourteen:14,fifteen:15,sixteen:16,seventeen:17,eighteen:18,nineteen:19,twenty:20,thirty:30,forty:40,fourty:40,fifty:50,sixty:60,seventy:70,eighty:80,ninety:90,pi:Math.PI,e:Math.E},o=function(a){return Math.pow(1e3,a)},c=["thousand","million","billion","trillion","quadrillion","quintillion","sextillion","septillion","octillion","nonillion","decillion","undecillion","duodecillion","tredecillion","quattuordecillion","quindecillion","sexdecillion","septendecillion","octodecillion","novemdecillion","vigintillion"],b={},d=0;d=0;b-=3){var c=[];a[b+2]>0&&c.push(f[a[b+2]],"hundred");if(a[b+1]==="1"){var h=a[b+1]*10+ +a[b];c.push(f[h])}else{a[b+1]>0&&c.push(k[a[b+1]]);a[b]>0&&c.push(f[a[b]])}b>0&&c.length&&c.push(j[b/3]);d=d.concat(c)}!d.length&&d.push("zero");e&&d.unshift("negative");return d.join(" ")};d=d.split(".");b.push(i(d[0].split("").reverse().join("")));if(d[1])for(var g=d[1],a=0;a1||a%3!==2)h+="s";b.push(h)}return b.join(" ")},a=function(b){return{value:b,add:function(c){return a(b+e(c).value)},subtract:function(c){return a(b-e(c).value)},multiply:function(c){return a(b*e(c).value)},divide:function(c){return a(b/e(c).value)},modulo:function(c){return a(b%e(c).value)},toPower:function(c){return a(Math.pow(b,e(c).value))},negate:function(){return a(-b)},absoluteValue:function(){return a(Math.abs(b))},round:function(){return a(Math.round(b))},floor:function(){return a(Math.floor(b))},ceiling:function(){return a(Math.ceil(b))},toSquareRoot:function(){return a(Math.sqrt(b))},sine:function(){return a(Math.sin(b))},cosine:function(){return a(Math.cos(b))},tangent:function(){return a(Math.tan(b))},arcSine:function(){return a(Math.asin(b))},arcCosine:function(){return a(Math.acos(b))},arcTangent:function(){return a(Math.atan(b))},toString:function(){return h(b)}}},g=function(a,b){if(b<1&&a>1)a=1/a;return a*b},e=function(j){if(typeof j!=="string"||!j.length)throw"Invalid number";for(var d=j.toLowerCase().split(/[^A-Za-z]+/),m=1,c=0;c0&&e<1e3){while(f.hasOwnProperty(d[c+1]))i+=f[d[++c]];e=1;while(b.hasOwnProperty(d[c+1]))e=g(e,b[d[++c]]);i=i*e}n+=i}else throw"Unexpected word: "+h;}return a(n*m)};j.wordMath=e;j.wordMath.toString=h})(jQuery)