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
10
votes
8 answers

How do I round an integer up to in Ruby?

Say I have any of the following numbers: 230957 or 83487 or 4785 What is a way in Ruby I could return them as 300000 or 90000 or 5000, respectively?
John
  • 3,430
  • 2
  • 31
  • 44
9
votes
6 answers

C++ significant figures

How can I do math involving significant figures in C++? I want this to work correct with measured data from chemistry and physics experiments. An example: 65 / 5 = 10. I would need to get rid of unneeded decimal places and replace some digits…
joshim5
  • 2,292
  • 4
  • 28
  • 40
8
votes
2 answers

Floor and ceiling with 2 or more significant digits

It is possible to round results into two significant digits using signif: > signif(12500,2) [1] 12000 > signif(12501,2) [1] 13000 But are there an equally handy functions, like the fictitious functions below signif.floor and signif.ceiling, so that…
Heikki
  • 2,214
  • 19
  • 34
8
votes
2 answers

Get most significant digit in python

Say I have list [34523, 55, 65, 2] What is the most efficient way to get [3,5,6,2] which are the most significant digits. If possible without changing changing each to str()?
Nicky Feller
  • 3,539
  • 9
  • 37
  • 54
7
votes
6 answers

Counting significant figures in Python?

Is there a way in Python to count the significant figures in a double/float/etc? I'm not seeing an easy way to do this, but I'd expect it to be in the library. Thanks in advance.
user456584
  • 86,427
  • 15
  • 75
  • 107
7
votes
3 answers

r keeping 0.0 when using paste or paste0

This is a simple question but it is starting to annoy me that I cant find a solution.... I would like to be able to keep the 0.0 when using it as an output when using paste or paste0 so if i have the following: y <-…
h.l.m
  • 13,015
  • 22
  • 82
  • 169
6
votes
3 answers

NSNumberFormatter to show a maximum of 3 digits

I would like to make it so one of my UILabels only shows a maximum of 3 digits. So, if the associated value is 3.224789, I'd like to see 3.22. If the value is 12.563, I'd like to see 12.5 and if the value is 298.38912 then I'd like to see 298. I've…
benwad
  • 6,414
  • 10
  • 59
  • 93
6
votes
3 answers

Postgresql rounding to significant figures

i've tried this significant figures query from this blog (https://www.garysieling.com/blog/postgres-significant-figures-pg_size_pretty). But it seems have fixed decimal digit on it. SELECT FLOOR(5.4321/(10 ^ FLOOR(log(5.4321)-1))) * (10 ^…
Rakaziwi
  • 171
  • 4
  • 16
6
votes
2 answers

Format double to at least one significant digit in Java/Android

I have a DecimalFormat object which I'm using to format all of my double values to a set number of digits (let's say 2) when I'm displaying them. I would like it to normally format to 2 decimal places, but I always want at least one significant…
Kyle Humfeld
  • 1,887
  • 4
  • 23
  • 28
6
votes
4 answers

Preventing double.Parse from removing trailing zeros after decimal place?

When using double.Parse, it seems to like to string away any trailing (insignificant) zeros from the string that I'm converting. I would like double.Parse to keep to places after the decimal. For example, here is some…
gcode
  • 2,954
  • 4
  • 21
  • 32
6
votes
1 answer

Rounding significant figures in R

So basically I am doing a physics experiment, and in my table I want to have my data rounded to the same accuracy as the error is, which is rounded to 1 sig fig. So for example if I have the following: angle <- c(4, 4.1, 4.2) angle.error <-…
Nick Siemons
  • 61
  • 1
  • 1
  • 3
6
votes
4 answers

String Format % with significant figures

I am using the following code to show percentage using String.Format but I also want to limit the number of significant figures to 2, the two don't seem to play well together. How can I get the two working together properly? String.Format("% Length…
Chris
  • 26,744
  • 48
  • 193
  • 345
6
votes
2 answers

How do I determine the number of significant figures in data in R?

I have a large dataset that I'm analyzing in R and I'm interested in one column or vector of information. Each entry in this vector has a varied number (ranging from 1-5) of significant figures, and I want to subset this vector so I'm not seeing…
pocketlizard
  • 379
  • 2
  • 4
  • 11
6
votes
1 answer

Rounding to n significant digits

I'm trying to write code in MATLAB that will round number to certain (as I ask) significant digits. I'm not sure how to do it. Any suggestions?
saharz
  • 77
  • 1
  • 1
  • 5
5
votes
3 answers

Extract n most significant non-zero bits from int in C++ without loops

I want to extract the n most significant bits from an integer in C++ and convert those n bits to an integer. For example int a=1200; // its binary representation within 32 bit word-size is // 00000000000000000000010010110000 Now I want to extract…
linello
  • 8,451
  • 18
  • 63
  • 109
1
2
3
11 12