HighDots Forums  

Re: FAQ Topic - How do I convert a Number into a String with exactly2 decimal places? (2008-06-20)

Javascript JavaScript language (comp.lang.javascript)


Discuss Re: FAQ Topic - How do I convert a Number into a String with exactly2 decimal places? (2008-06-20) in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Thomas 'PointedEars' Lahn
 
Posts: n/a

Default Re: FAQ Topic - How do I convert a Number into a String with exactly2 decimal places? (2008-06-20) - 06-23-2008 , 12:21 PM






yukabuk wrote:
Quote:
You should write this...
This -- what? --> <http://www.jibbering.com/faq/#FAQ2_3>

Quote:
var numberObj = new Number(6.57634);
There is no point in creating a Number object there, ...

Quote:
var formattedNumber = numberObj.toFixed(2);
.... as it is created here implicitly.

var formattedNumber = (6.57634).toFixed(2);

or, parametrized:

var numberValue = 6.57634;
var formattedNumber = numberValue.toFixed(2);

However, you have missed this:

Quote:
ECMAScript Ed. 3.0 (JScript 5.5 [but buggy] and JavaScript 1.5)
introduced N.toFixed, the main problem with this is the bugs in
JScripts implementation.

PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f806at$ail$1$8300dec7 (AT) news (DOT) demon.co.uk>


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.