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

159 questions
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
  • 5,676
  • 8
  • 52
  • 89
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,797
  • 3
  • 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…
TGP1994
  • 2,786
  • 4
  • 17
  • 31
6
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
  • 2,539
  • 4
  • 29
  • 49
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
  • 24,827
  • 43
  • 179
  • 317
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
  • 369
  • 1
  • 4
  • 10
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
  • 4
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
  • 7,476
  • 14
  • 53
  • 98
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
  • 21,270
  • 21
  • 97
  • 131
5
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,150
  • 14
  • 27
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
  • 17,745
  • 33
  • 112
  • 182
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
  • 6,920
  • 23
  • 74
  • 143
5
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
  • 11,457
  • 18
  • 73
  • 155
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
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
  • 131
  • 2
  • 15
1
2
3
10 11