significant-digits

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

一笑奈何 提交于 2019-12-10 13:24:30
问题 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 data with only one significant digit. What kind of test or function can I use to get R to report the number of significant figures for each entry? I've looked into the signif() function but that is more for rounding data to a specified number of

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

人走茶凉 提交于 2019-12-07 12:01:16
问题 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 about entirely different problems. I want to know why the function about does not return the desired value for a specific input. None of the answers to Significant figures in the decimal module address this question. The following function is

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

一个人想着一个人 提交于 2019-12-06 02:05:00
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 about entirely different problems. I want to know why the function about does not return the desired value for a specific input. None of the answers to Significant figures in the decimal module address this question. The following function is supposed to return a string representation of a float with the specified number of significant figures:

C++ significant figures

依然范特西╮ 提交于 2019-12-04 21:20:08
问题 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 with 0s. Thanks! 回答1: Well there are good math libraries in math.h Also storing your figures in floats, doubles or long doubles will allow for more precise operations. Floats offer 7 significant digits while doubles offer 16 significant digits. source

Built in methods for displaying Significant figures

ぐ巨炮叔叔 提交于 2019-12-04 04:09:25
问题 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 questions and solutions are around 2009~2010. I want to have a simple built in method (or from standard well know libraries such as from Apache or Spring) that given the number and significant figures, prints out the number limited to the specified

r keeping 0.0 when using paste or paste0

与世无争的帅哥 提交于 2019-12-04 03:26:58
问题 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 <- c(-1.5,-1.0,-0.5,0.0,0.5,1.0,1.5) > y [1] -1.5 -1.0 -0.5 0.0 0.5 1.0 1.5 paste0("x",y,"x") I get: [1] "x-1.5x" "x-1x" "x-0.5x" "x0x" "x0.5x" "x1x" "x1.5x" but want: [1] "x-1.5x" "x-1.0x" "x-0.5x" "x0.0x" "x0.5x" "x1.0x" "x1.5x" 回答1: You can use sprintf() : paste0("x", sprintf("%

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

。_饼干妹妹 提交于 2019-12-03 15:37:39
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 the 4 most significant digits from that representation, i.e. 1111 00000000000000000000010010110000 ^^^^ and convert them again to an integer (1001 in decimal = 9). How is possible with a simple c++ function without loops? Mike Seymour Some processors have an instruction to count the leading binary zeros of an integer, and some compilers have

C++ significant figures

孤街浪徒 提交于 2019-12-03 13:42:38
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 with 0s. Thanks! Well there are good math libraries in math.h Also storing your figures in floats, doubles or long doubles will allow for more precise operations. Floats offer 7 significant digits while doubles offer 16 significant digits. source Also when printing out usually people use _snprintf or printf and you can format those doubles, floats to the

Rounding with significant digits

女生的网名这么多〃 提交于 2019-12-01 06:53:28
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. Nate Thorn I didn't run this through a compiler to double-check it, but here's the basic jist of the algorithm (converted from the answer to this question ): -(float) round:(float)num toSignificantFigures:(int)n { if(num == 0) { return 0; } double d = ceil(log10(num < 0 ? -num: num)); int power = n - (int) d; double magnitude = pow(10, power); long shifted = round(num*magnitude)

How to get excel to display a certain number of significant figures?

こ雲淡風輕ζ 提交于 2019-12-01 04:10:39
I am using excel and i want to display a value to a certain number of significant figures. I tried using the following equation =ROUND(value,sigfigs-1-INT(LOG10(ABS(value)))) with value replaced by the number I am using and sigfigs replaced with the number of significant figures I want. This formula works sometimes, but other times it doesn't. For instance, the value 18.036, will change to 18, which has 2 significant figures. The way around this is to change the source formatting to retain 1 decimal place. But that can introduce an extra significant figure. For instance, if the result was 182