Rounding a Number to a String with N decimal places

Discussion in 'Javascript' started by Dr John Stockton, Aug 15, 2004.

  1. When rounding (or truncating) a number which may be either positive or
    negative, it is sometimes necessary to round either towards plus
    infinity or towards minus infinity. But those are special cases.

    Normally, however, rounding should be symmetrical about zero; rounding X
    should give the same digits as rounding -X, for all X.

    Some of the signed routines which have been quoted here and elsewhere
    are unsymmetrical.

    --
    © John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
    <URL:http://jibbering.com/faq/> JL / RC : FAQ for news:comp.lang.javascript
    <URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
    <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
     
    Dr John Stockton, Aug 15, 2004
    #1
    1. Advertising

  2. Dr John Stockton

    G Roydor Guest

    Dr John Stockton a écrit:
    > When rounding (or truncating) a number which may be either positive or
    > negative, it is sometimes necessary to round either towards plus
    > infinity or towards minus infinity. But those are special cases.
    >
    > Normally, however, rounding should be symmetrical about zero; rounding X
    > should give the same digits as rounding -X, for all X.


    Non

    2 < 2.x < 3 => 2 ou 3

    -3 < -2.x < -2 => 3 ou 2

    GR


    >
    > Some of the signed routines which have been quoted here and elsewhere
    > are unsymmetrical.
    >
     
    G Roydor, Aug 15, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gary Mayor

    Rounding up to 2 decimal places

    Gary Mayor, Dec 9, 2003, in forum: Perl Misc
    Replies:
    6
    Views:
    230
    Anno Siegel
    Dec 10, 2003
  2. FAQ server
    Replies:
    1
    Views:
    151
    Bart Van der Donck
    Aug 19, 2006
  3. FAQ server
    Replies:
    6
    Views:
    169
    Dr J R Stockton
    Nov 3, 2006
  4. FAQ server
    Replies:
    52
    Views:
    524
  5. VK
    Replies:
    19
    Views:
    153
    Dr J R Stockton
    Jan 30, 2007
Loading...

Share This Page