Flash Website Builder- Trendy Site Builder is a Flash Site Building tool that helps users build stunning websites. Check Out Custom Custom Logo Design by LogoBee. Website Design and Free Logo Templates available.
 CodingForums.com Number.toLongString() method for extremely large values

Before you post, read our: Rules & Posting Guidelines

Enjoy an ad free experience by logging in. Not a member yet? Register.
 02-01-2003, 08:49 AM PM User | #1 Algorithm Regular Coder   Join Date: Jul 2002 Location: USA Posts: 151 Thanks: 0 Thanked 0 Times in 0 Posts Number.toLongString() method for extremely large values Update 02-01-03: Changed as per recommendations. The standard Number.toString() method returns values in scientific notation once they exceed 10^20. In many cases, this is not an expected or desired result. The toLongString() method provides a solution by always returning a literal numeric value regardless of the number's size. However, the value returned will not be accurate beyond the first [log base (radix) of (10^15)] digits. radix: Optional. A number between 2 and 36, inclusive. Code: ```Number.prototype.toLongString = function(){ var radix, n = this, d, t = '', p = ''; if(arguments.length>0 && typeof(arguments[0])=='number'){ radix = Math.round(arguments[0]); if(radix<2) radix = 2; if(radix>36) radix = 36; } else { radix = 10; } if(n < 0){ n *= -1; p = '-'; } while(n > radix){ d = n % radix; n = (n-d)/radix; t = d.toString(radix) + t; } return p + n.toString(radix) + t; }``` Last edited by Algorithm; 02-01-2003 at 09:25 PM..
 02-01-2003, 08:05 PM PM User | #2 Alex Vincent Moderator   Join Date: May 2002 Location: Hayward, CA Posts: 1,445 Thanks: 1 Thanked 21 Times in 19 Posts You'll get a JavaScript strict warning from that in Mozilla browsers. http://www.javascriptkit.com/javatutors/serror.shtml I'd suggest: Code: ```Number.prototype.toLongString = function(){ if (arguments.length > 0) { var radix = arguments[0]; } else { radix = 10; } // ...``` __________________ "The first step to confirming there is a bug in someone else's work is confirming there are no bugs in your own." June 30, 2001 author, Verbosio prototype XML Editor author, JavaScript Developer's Dictionary https://alexvincent.us/blog
 02-01-2003, 09:26 PM PM User | #3 Algorithm Regular Coder   Join Date: Jul 2002 Location: USA Posts: 151 Thanks: 0 Thanked 0 Times in 0 Posts Good point. The necessary changes have been made.

 Bookmarks

 Thread Tools Rate This Thread Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is Off HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home :: Client side development     JavaScript programming         DOM and JSON scripting         Ajax and Design         JavaScript frameworks         Post a JavaScript     HTML & CSS     XML     Flash & ActionScript         Adobe Flex     Graphics and Multimedia discussions     General web building         Site reviews         Building for mobile devices :: Server side development     Apache configuration     Perl/ CGI     PHP         Post a PHP snippet     MySQL         Other Databases     Ruby & Ruby On Rails     ASP     ASP.NET     Java and JSP     Other server side languages/ issues         ColdFusion         Python :: Computing & Sciences     Computer Programming     Computer/PC discussions     Geek News and Humour Web Projects and Services Marketplace     Web Projects         Small projects (quick fixes and changes)         Medium projects (new script, new features, etc)         Large Projects (new web application, complex features etc)         Unknown sized projects (request quote)         Vacant job positions         Looking for work/ for hire         Project collaboration/ partnership         Paid work offers and requests (Now CLOSED)     Career, job, and business ideas or advice     Domains, Sites, and Designs for sale         Domains for sale         Websites for sale         Design templates and graphics for sale :: Other forums     Member Offers     Forum feedback and announcements

All times are GMT +1. The time now is 05:23 AM.