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   
Dr J R Stockton
 
Posts: n/a

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






On Jun 21, 8:53*am, "Evertjan." <exjxw.hannivo... (AT) interxnl (DOT) net> wrote:
Quote:
Dr J R Stockton wrote on 20 jun 2008 in comp.lang.javascript:

I would like to add my latest version for 'any' integer d >= 0:

Fails, I think, for n=1.11, d>21 ; also for n = infinity, NaN. *

With quoted 'any', I ment any reasonable. ;-)

Catching all possibilities makes the code sound but unreadable for
instruction.
It is only necessary to include a test that s is all-digit, such as
if (/\D/.test(d)) return n // cannot cope

IMHO, d=0 should be allowed; it should give results such as "3." which
is deprecated but not wrong.


Quote:
Sorry, John, your server seems down.
<QUOTE>
We will be carrying out planned maintenance of our Web Hosting
platform as follows:
Saturday 21st June between 00:01 and 20:00 Hrs BST
Saturday 28th June between 00:01 and 04:00 Hrs BST
Sunday 29th June between 00:01 and 04:00 Hrs BST
</QUOTE>

--
(c) John Stockton, near London, UK. Posting with Google.
Mail: J.R.""""""""@physics.org or (better) via Home Page at
Web: <URL:http://www.merlyn.demon.co.uk/>
FAQish topics, acronyms, links, etc.; Date, Delphi, JavaScript, ...



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.