Questions tagged [significant-digits]

Significant digits are a way of describing the precision of measurements in a scale-independent way.

Typically if a number is in normal scientific notation, the number of significant digits is the length (number of digits) of the mantissa or significand. The significant figures of a number are those digits that carry meaning contributing to its precision. This includes all digits except: All leading zeros, Trailing zeros when they are merely placeholders to indicate the scale of the number (exact rules are explained at Identifying significant figures), and spurious digits introduced, for example, by calculations carried out to greater precision than that of the original data, or measurements reported to a greater precision than the equipment supports.

Numbers are often rounded to avoid reporting insignificant figures. For instance, if a device measures to the nearest gram and gives a reading of 12.345 kg, it would create false precision to express this measurement as 12.34500 kg. Significant Figures - Wikipedia

178 questions
5
votes
8 answers

How to round down to the nearest significant figure in php

Is there any slick way to round down to the nearest significant figure in php? So: 0->0 9->9 10->10 17->10 77->70 114->100 745->700 1200->1000 ?
Kzqai
  • 22,588
  • 25
  • 105
  • 137
5
votes
3 answers

Neat way to find the number of significant digits in a BigDecimal?

I do not want to limit the number of significant digits in a BigDecimal. I only want to find the number of significant digits that number has. Is there a way to do this without converting the number to string and count the number characters?
0x56794E
  • 20,883
  • 13
  • 42
  • 58
5
votes
3 answers

Round numbers in output to show small near-zero quantities as zero

I would like the output of my R console to look readable. To this end, I would like R to round all my numbers to the nearest N decimal places. I have some success but it doesn't work completely: > options(scipen=100, digits=4) > .000000001 [1]…
Alex
  • 19,533
  • 37
  • 126
  • 195
5
votes
1 answer

Show 2 decimals places (unless there are more significant digits)

Possible Duplicate: Display Float as String with at Least 1 Decimal Place Given the following values: 23.50 15 19.3500 31.505 45.6670 How can I achieve the following display: 23.50 15.00 19.35 31.505 45.667 What I am trying to do is force 2…
Brian David Berman
  • 7,514
  • 26
  • 77
  • 144
4
votes
1 answer

Rounding with significant digits

In Xcode /Objective-C for the iPhone. I have a float with the value 0.00004876544. How would I get it to display to two decimal places after the first significant number? For example, 0.00004876544 would read 0.000049.
4
votes
4 answers

How to get first significant figure from a number in Excel?

I have a column of numbers in Excel 2016. The numbers span many orders of magnitude, but are all positive. Some are less than zero. How can I return the first significant figure of each cell in a new column? For example, for the number 1.9 the…
indigochild
  • 350
  • 1
  • 5
  • 21
4
votes
2 answers

How to round only the numeric values in a dataframe?

I'm trying to round all numerical values in my data frame. The issue is that my data frame also includes strings, and not just in any particular column or row. I want to avoid having to code a loop where I go through each individual row-column cell…
stargirl
  • 129
  • 1
  • 2
  • 12
4
votes
4 answers

C++ `digits10` is 6 for IEEE float, but the first non-representable integer already has 8 digits?

C++'s std::numeric_limits::digits10, is described on cppref as such: The value of std::numeric_limits::digits10 is the number of base-10 digits that can be represented by the type T without change, that is, any number with this many…
Martin Ba
  • 37,187
  • 33
  • 183
  • 337
4
votes
1 answer

Is there any way to print at least 20 significant figures in Octave?

I need to print the result of a program with 20 significant figures, but I don't know how to print more than 15 figures (format long). Is there any way to achieve this?
Jk041
  • 934
  • 1
  • 15
  • 33
4
votes
2 answers

Why doesn't python decimal library return the specified number of signficant figures for some inputs

NB: this question is about significant figures. It is not a question about "digits after the decimal point" or anything like that. EDIT: This question is not a duplicate of Significant figures in the decimal module. The two questions are asking…
kjo
  • 33,683
  • 52
  • 148
  • 265
4
votes
1 answer

significant decimal digits of binary32 and binary64

Accourding to Wikipedia the binary32 format has from 6 to 9 significant decimal digits precision and 64 format has from 15 to 17. I found that these significant decimal digits have been calculated using the Mantissa but i didn't get it how can…
4
votes
2 answers

Built in methods for displaying Significant figures

There's been a lot of questions on rounding by significant figures, and answers that that provides a new method to do the rounding, such as: Rounding to an arbitrary number of significant digits Round a double to 2 decimal places Most of these…
JackDev
  • 11,003
  • 12
  • 51
  • 68
4
votes
6 answers

Save list to csv with two decimal digits in python?

I have data which looks like [('A',5.3748),('B',8.324203),('C',3.492)] I'm saving it to a csv with the following lines: with open('output.csv','wb') as fp: a = csv.writer(fp,delimiter = ",") a.writerows(data) Works like a charm except…
marc
  • 2,037
  • 9
  • 24
  • 32
4
votes
2 answers

Accuracy of numerical integration in Matlab

I am trying to integrate an analytic function (a composite of sqrt and trig function) on a rectangle area. It has no singularity point in the area and seems to be a perfect candidate to use dblquad. My question is how to evaluate the accuracy of the…
4
votes
4 answers

Convert a number from stringstream to string with a set precision

I would like to obtain a number from stringstream and set it to 5 significant figures. How do I do this? So far, this is what I have managed to come up with: double a = 34.34566535 std::stringstream precisionValue; precisionValue.precision(6) << a…
programmingNoob
  • 141
  • 2
  • 3
  • 8
1 2
3
11 12