Output to N significant figures, fixed-point and exponential

D

Dr John Stockton

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.?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top