scientific-notation

Java : How to count the number of decimals contained in a double value that represent money?

扶醉桌前 提交于 2019-12-08 08:45:10
问题 For a change-making application, made with Java, I am facing a problem while counting the number of decimals in a double value. The double value represent money, so all my operations must be made in consequences that a double value like 12.58 can be stored as 12.5797886 after an operation is made on the original value. To counter this effect, I chose to use String, just like this : String amountString = String.valueOf(amount); String decimals = amountString.substring(amountString.indexOf('.')

Python Pandas Scientific Notation Iconsistent

爱⌒轻易说出口 提交于 2019-12-08 05:47:28
问题 I am looking into rewriting some data analysis code using Pandas (since I just discovered it) on Ubuntu 14.04 64-bit and I have hit upon some strange behaviour. My data files look like this: 26/09/2014 00:00:00 2.423009 -58.864655 3.312355E-7 6.257226E-8 302 305 26/09/2014 00:00:00 2.395637 -62.73302 3.321525E-7 7.065322E-8 302 305 26/09/2014 00:00:01 2.332541 -57.763269 3.285718E-7 6.873837E-8 302 305 26/09/2014 00:00:02 2.366828 -51.900812 3.262279E-7 7.397762E-8 302 305 26/09/2014 00:00:03

Angularjs avoid scientific notation for number filter

久未见 提交于 2019-12-07 18:00:19
问题 I need to print very small numbers for my app. I prefer if they were all displayed in decimal format. Is there a way to do this with the angularjs number filter or do I have to write my own or modify the existing one somehow? http://jsfiddle.net/ADukg/2386/ Javascript var myApp = angular.module('myApp',[]); function MyCtrl($scope) { $scope.MyNum1 = 0.000001; $scope.MyNum2 = 0.0000001; } HTML <div ng-controller="MyCtrl"> Small Number: {{MyNum1 | number:8}}<br/> Very Small Number: {{MyNum2 |

Convert double to scientific notation with specific number after decimal points

╄→гoц情女王★ 提交于 2019-12-07 12:23:35
问题 I want to convert double to scientific notation like this: -0.00752382528 => -.752383E-1 can i do this with .ToString() or Regex? 回答1: You can either use the standard format string for scientific notation: (-0.00752382528).ToString("E5") // returns "-7.52383E-003" or if you don't want the leading zeros in the exponent, use a custom string: (-0.00752382528).ToString("0.00000E0") // returns "-7.52383E-3" 来源: https://stackoverflow.com/questions/25851179/convert-double-to-scientific-notation-with

Converting a working code from double-precision to quadruple-precision: How to read quadruple-precision numbers in FORTRAN from an input file

↘锁芯ラ 提交于 2019-12-07 11:05:23
问题 I have a big, old, FORTRAN 77 code that has worked for many, many years with no problems. Double-precision is not enough anymore, so to convert to quadruple-precision I have: Replaced all occurrences of REAL*8 to REAL*16 Replaced all functions like DCOS() into functions like COS() Replaced all built-in numbers like 0.d0 to 0.q0 , and 1D+01 to 1Q+01 The program compiles with no errors or warnings with the gcc-4.6 compiler on operating system: openSUSE 11.3 x86_64 (a 64-bit operating system)

Java DecimalFormat Scientific Notation Question

狂风中的少年 提交于 2019-12-07 06:33:19
问题 I'm using Java's DecimalFormat class to print out numbers in Scientific Notation. However, there is one problem that I have. I need the strings to be of fixed length regardless of the value, and the sign on the power of ten is throwing it off. Currently, this is what my format looks like: DecimalFormat format = new DecimalFormat("0.0E0"); This gives me the following combinations: 1.0E1, 1.0E-1, -1.0E1, and -1.0E-1. I can use setPositivePrefix to get: +1.0E1, +1.0E-1, -1.0E1, and -1.0E-1, or

bcdiv using very small float with scientific notation cause “Division by zero” error

我是研究僧i 提交于 2019-12-06 04:09:55
Using bcdiv, i can't divide with small float using scientific notation : Working code : bcscale(30); $a = '1' ; $b = '0.00000001'; $result = bcdiv($a, $b); var_dump($result); Results in : string(20) "100000000.0000000000" Non-working code : bcscale(30); $a = '1' ; $b = '1e-8'; $result = bcdiv($a, $b); var_dump($result); Results in : Warning: bcdiv() [function.bcdiv]: Division by zero in C:\wamp\www\utilitaires\test_bcdiv.php on line XX NULL How can i do this division properly, with the less precision loss ? That is because, actually, bcmath doesn't support scientific notation. It isn't

R scientific notation in plots

可紊 提交于 2019-12-05 23:40:54
问题 I have a simple plot: #!/usr/bin/Rscript png('plot.png') y <- c(102, 258, 2314) x <- c(482563, 922167, 4462665) plot(x,y) dev.off() R uses 500, 1000, 1500, etc for the y axis. Is there a way I can use scientific notation for the y axis and put * 10^3 on the top of the axis like the figure below? 回答1: This is sort of a hacky way, but there's nothing wrong with it: plot(x,y/1e3, ylab="y /10^3") 回答2: A similar technique is to use eaxis (extended / engineering axis) from the sfsmisc package. It

How to read float with scientific notation from file C++?

一世执手 提交于 2019-12-05 20:50:10
I have a file with this format: -0.0064785667 0.73900002 0.028505694 4.7858757e-39 315 218 -0.0051828534 0.73900002 0.028505694 4.6936954e-39 316 218 -0.0038818798 0.73799998 0.028467119 5.1546736e-39 317 218 -0.0025879198 0.73799998 0.028467119 5.6160217e-39 318 218 -0.0012939599 0.73799998 0.028467119 6.4461411e-39 319 218 I read it with this code: using namespace std; ifstream inputFile; //Opens data file for reading. inputFile.open(filePath.c_str()); //Creates vector, initially with 0 points. vector<Point> data(0); float temp_x,temp_y,temp_z,rgb=0,discard_1=0,discard_2=0; //Read contents

Convert double to scientific notation with specific number after decimal points

China☆狼群 提交于 2019-12-05 20:46:19
I want to convert double to scientific notation like this: -0.00752382528 => -.752383E-1 can i do this with .ToString() or Regex? You can either use the standard format string for scientific notation: (-0.00752382528).ToString("E5") // returns "-7.52383E-003" or if you don't want the leading zeros in the exponent, use a custom string : (-0.00752382528).ToString("0.00000E0") // returns "-7.52383E-3" 来源: https://stackoverflow.com/questions/25851179/convert-double-to-scientific-notation-with-specific-number-after-decimal-points