Output to N significant figures, fixed-point and exponential

Discussion in 'Javascript' started by Dr John Stockton, Jul 17, 2005.

  1. Occasional problems have been found in the old functions SigFigNo and
    SigFigExp used on my web site (toFixed, toExponential, and toPrecision
    are not available to me, even if they do what I want) - they are
    intended to present results to a given number of significant figures
    (the StrU family provides a given number of decimal places, which is not
    the same).

    New replacement code is at
    <URL:http://www.merlyn.demon.co.uk/js-index.htm#DoRV> and needs testing.

    There are comparatively brief methods using mainly arithmetic, which can
    show rounding error, and somewhat longer ones relying more on string
    manipulation. They handle undefined, Infinity, and NaN.

    I don't mind if a fixed-point method reverts to javascript default
    format for numbers of unreasonable size.

    Would anyone like to inspect, comment, offer alternatives, etc.?

    --
    © John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
    <URL:http://www.jibbering.com/faq/> JL/RC: FAQ of 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, Jul 17, 2005
    #1
    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. Steve
    Replies:
    5
    Views:
    42,678
    Steve
    May 17, 2004
  2. Jeremy Watts

    more than 16 significant figures

    Jeremy Watts, Jul 4, 2005, in forum: Java
    Replies:
    32
    Views:
    1,320
    Tom N
    Jul 15, 2005
  3. Alf P. Steinbach

    Re: Round to significant figures (C++)

    Alf P. Steinbach, May 1, 2006, in forum: C++
    Replies:
    0
    Views:
    728
    Alf P. Steinbach
    May 1, 2006
  4. Harold

    Significant figures calculation

    Harold, Jun 24, 2011, in forum: Python
    Replies:
    16
    Views:
    1,202
  5. SMH
    Replies:
    0
    Views:
    223
Loading...

Share This Page