Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #18939

Re: FAQ Topic - How do I format a Number as a String with exactly 2 decimal places? (2013-03-15)

From Dr J R Stockton <reply1300@merlyn.demon.co.uk.invalid>
Newsgroups comp.lang.javascript
Subject Re: FAQ Topic - How do I format a Number as a String with exactly 2 decimal places? (2013-03-15)
Date 2013-03-18 19:21 +0000
Organization Home
Message-ID <qVd8etJBl2RRFwyr@invalid.uk.co.demon.merlyn.invalid> (permalink)
References <51426487$0$32115$14726298@news.sunsite.dk> <XnsA18460B31AE76eejj99@194.109.133.133> <aZewtRTO6MRRFw0Z@invalid.uk.co.demon.merlyn.invalid> <XnsA186C77818CE7eejj99@194.109.133.133>

Show all headers | View raw


In comp.lang.javascript message <XnsA186C77818CE7eejj99@194.109.133.133>
, Sun, 17 Mar 2013 19:36:30, Evertjan. <exxjxw.hannivoort@inter.nl.net>
posted:


>No reason why it should work with null.
>Should it work for n = 'blah';,
>or for n being an object?

A FAQ Number formatting routine should give correct results for all
values of the type Number.  Users who have confidence (often misplaced)
that some values will not occur can simplify the code if they need to.

For pedagogical reasons, maybe the FAQ answer should include an initial
test, commented out, that the input is indeed a Number.  With your
(original) code,   formatNumber2(formatNumber2)   returns NaN, which is
not ideal.  The result of a function call should never be misleading.

My Web site includes good, indifferent, and bad formatters.

-- 
 (c) John Stockton, nr London, UK.   E-mail, see Home Page.    Turnpike v6.05.
 Website  <http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
 PAS EXE etc. : <http://www.merlyn.demon.co.uk/programs/> - see in 00index.htm
 Dates - miscdate.htm estrdate.htm js-dates.htm pas-time.htm critdate.htm etc.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

FAQ Topic - How do I format a Number as a String with exactly 2 decimal places? (2013-03-15) "FAQ server" <javascript@dotinternet.be> - 2013-03-15 00:00 +0000
  Re: FAQ Topic - How do I format a Number as a String with exactly 2 decimal places? (2013-03-15) "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-03-15 09:30 +0100
    Re: FAQ Topic - How do I format a Number as a String with exactly 2 decimal places? (2013-03-15) Dr J R Stockton <reply1300@merlyn.demon.co.uk.invalid> - 2013-03-16 19:57 +0000
      Re: FAQ Topic - How do I format a Number as a String with exactly 2 decimal places? (2013-03-15) "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-03-17 19:36 +0100
        Re: FAQ Topic - How do I format a Number as a String with exactly 2 decimal places? (2013-03-15) Dr J R Stockton <reply1300@merlyn.demon.co.uk.invalid> - 2013-03-18 19:21 +0000
          Re: FAQ Topic - How do I format a Number as a String with exactly 2 decimal places? (2013-03-15) "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-03-19 08:43 +0100

csiph-web