Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- Number formatting for IdleGameMaker.
- */
- (function(){
- var MODULE_KEY = 'numberformat_gw4y480hjear';
- if (window[MODULE_KEY]) {
- return;
- }
- var oldFunction = window.Beautify;
- if (!oldFunction) {
- alert('Could not find Beautify() function!');
- return;
- }
- window.Beautify = function(what, floats) {
- if (!isFinite(what) || isNaN(what)) {
- return '' + what;
- }
- if (what == 0) {
- return '0';
- }
- var prefix = what < 0 ? '-' : '';
- var base = Math.abs(what);
- if (base < 1) {
- return base.toLocaleString();
- }
- if (base < 1e12) {
- var a = Math.floor(base).toLocaleString();
- var b = base % 1;
- if (b && floats && base < 1e6) {
- a += b.toFixed(floats).slice(1);
- }
- return prefix + a;
- }
- var exp = 0;
- while (base >= 1e3) {
- base = base / 1e3;
- exp += 3;
- }
- return prefix + base.toFixed(3) + '_e' + exp;
- };
- window[MODULE_KEY] = oldFunction;
- })();
Advertisement
Add Comment
Please, Sign In to add comment