I have a requirement to format a no to get 3 significant digit after a decimal in javascript..
detail about the significant digit can be found here http://www.usca.edu/chemistry/genchem/sigfig.htm
here are the rule for significant digit
1) ALL non-zero numbers (1,2,3,4,5,6,7,8,9) are ALWAYS significant.
2) ALL zeroes between non-zero numbers are ALWAYS significant.
3) ALL zeroes which are SIMULTANEOUSLY to the right of the decimal point AND at the end of the number are ALWAYS significant.
4) ALL zeroes which are to the left of a written decimal point and are in a number >= 10 are ALWAYS significant.
i want function like function significantDigit(no, noOfDecimal) { return signifcantNo }
Example of significant digits. 48,923 has five significant digit..significantDigit(no,3) should return 48923 3.967 has four significant digit..significantDigit(no,3) should return 3.967 0.00104009 has six significant digit,..significantDigit(no,3) should return .00104