c++,arrays,char,double,scientific-notation

As T.C. suggest, use strtod. But check the return pointer to see if it read all the content. #include <stdio.h> #include <string.h> #include <stdlib.h> double convert_number( const char * num ) { char * endptr = 0; double retval; retval = strtod( num, &endptr ); return ( !endptr || (...

r,table,scientific-notation,stargazer,coefficients

Here's a reproducible example: m1 <- lm(Sepal.Length ~ Petal.Length*Sepal.Width, transform(iris, Sepal.Length = Sepal.Length+1e6, Petal.Length=Petal.Length*10, Sepal.Width=Sepal.Width*100)) # Coefficients: # (Intercept) Petal.Length Sepal.Width Petal.Length:Sepal.Width # 1.000e+06 7.185e-02 8.500e-03 -7.701e-05 I don't believe stargazer has easy support for this. You could try other alternatives like xtable or any of the many options here...

java,string,decimal,bigdecimal,scientific-notation

If you look at the toString() function of BigDecimal, it explains how the output is created: Next, an adjusted exponent is calculated; this is the negated scale, plus the number of characters in the converted unscaled value, less one. That is, -scale+(ulength-1), where ulength is the length of the absolute...

If you do "{:.3e}".format(x) you will get 3 digits after decimal, that is >>> a = 31234.34234 >>> "{:.3e}".format(a) '3.123e+04' To get what you want, you need to do "{:.2e}".format(x). >>> "{:.2e}".format(a) '3.12e+04' >>> float("{:.2e}".format(a)) 31200.0 Converting it back to float will give you the original value As a function...

The printf "%12.5e" format instructs printf to convert the double (or float) argument to a string in exponential notation with 5 digits after the . and a total of at least 12 characters. In your example, the output actually contains an extra space before the number: 3.02530e+01 to make for...

java,scale,bigdecimal,scientific-notation

If I understand you correctly, d = d.setScale(0) will work: BigDecimal d = BigDecimal.valueOf(1e3).setScale(-3); System.out.println(d.unscaledValue()); d = d.setScale(0); System.out.println(d.unscaledValue()); Output is: 1 1000 Note that BigDecimal is immutable, thus you have to reassign it....

csv,import,scientific-notation

Use the system command to shell out to the operating system and invoke awk or similar to make sense of and reformat your input data. Something like this (untested) awk '/m/ {print $1/1000} /n/ {print $1/1000000000} ' stupid.csv > sensible.csv ...

In the first example , 4e means, 4 decimal places in scientific notation. You can come to know that by doing >>> print('{:.4e}'.format(3454356.7)) 3.4544e+06 >>> print('{:.5e}'.format(3454356.7)) 3.45436e+06 >>> print('{:.6e}'.format(3454356.7)) 3.454357e+06 In the second example, .4 , means 4 significant figures. And 2 means to fit the whole data into 2...

What you want to use is %lf for input and %e for output in scientific notation: scanf("%lf", &input); printf("%e\n", input); ...

Even if the .csv file is saved without scientific notation, spreadsheet software like Excel will display them in scientific notation. Some options to check the real output are: Open the file in a simple text editor, like Notepad or Gedit Use readLines("file.csv") on R. Print the file contents in terminal...

I would use this: xargs -n 8 < file | awk '{for (i=1;i<NF;i++) printf ("%13.6e%s", $i, FS); printf ("%13.6e\n", $NF)}' xargs -n X < file comes from your previous question: How to format the data of a file in Unix? awk '{for (i=1;i<NF;i++) printf ("%13.6e%s", $i, FS); printf ("%13.6e\n", $NF)}'...

php,numbers,scientific-notation

As long as there are less than 14 significant digits, printf(%f) works fairly well: $big = 1234567890123456; echo $big, "\n"; # 1.2345678901235E+15 printf("%.0f\n", $big); # 1234567890123456 If you need more, consider BCMath/GMP...

floating-point,numbers,ieee-754,scientific-notation

Since float has about 7 significant digits, you should switch to scientific notation if log10(abs(x)) > 7 or log10(abs(x)) < -7. Update: As the float still has binary format, it's better to focus on binary values. It has 23 significant binary digits, so you can check abs(x) > 223 and...

python,string,decimal,scientific-notation

If you want to reproduce your decimal, just construct it from the string: >>> d=decimal.Decimal("0E-1000") >>> str(d) '0E-1000' I believe the difference is the difference between 0 and 0.00000 (or in your case 1000 zeros), which is the accuracy. This could be significant in scientific situations, where rounding etc. is...

r,plot,legend,raster,scientific-notation

This is a try. It will need more refinement: library(rasterVis) set.seed(10) x = runif(2000000, -0.0005, .9875) y = runif(2000000, -0.0008, .99) xmat = matrix(x, nrow = 500) ymat = matrix(x, nrow = 500) xras = raster(xmat) yras = raster(ymat) min_ = min(minValue(xras), minValue(yras)) max_ = max(maxValue(xras), maxValue(yras)) r.range = c(min_,...

python,python-2.7,scientific-notation

Use string formatting, which gives you all the control you need over the formatting of floating point values: print '= {:.3e} m^3/min'.format(W_ / 1000) The .3 is the precision (3 decimal digits), the e tells the floating point object to use scientific notation. Note that I only needed to create...

You can try library(stringr) unlist(str_extract_all(txt, '-?[0-9.]+e?[-+]?[0-9]*')) #[1] "2.22222222e-200" "3.33333e4" "-1.33333e-40" "2.22222222-200" Using method based on capturing after leading parentheses str_extract(txt, '(?<=\\()[^)]*') #[1] "2.22222222e-200" "3.33333e4" "-1.33333e-40" "2.22222222-200" ...

c++,solaris,precision,double-precision,scientific-notation

You could declare norm as a long double for some more precision. long double wiki Although there are some compiler specific issues to be aware of. Some compilers make long double synonymous with double. Another way to go about solving this precision problem is to work with numbers in the...

You may need to use lapply(mferg_matrix, function(x) { x[] <- lapply( lapply(x,gsub, pattern = ",", replacement= "."), as.numeric) x}) data mferg_matrix <- list(structure(list(X2 = c("1,606E-07", "2,883E-07"), X3 = c("1,642E-07","2,789E-07"), X4 = c("1,731E-07", "2,554E-07")), .Names = c("X2", "X3", "X4"), class = "data.frame", row.names = c("84", "85")), structure(list(X2 = c("1,606E-07", "2,883E-07"), X3...

haskell,floating-point,formatting,floating-point-precision,scientific-notation

After some research, I manage to get what I want. The function to get the engineering format work in a few steps : 1. Dissociate the exponent from the mantissa It's necessary to get the exponent apart of the mantissa. The function decodeFloat (provided by base) decode a floating point...

c++,unix,precision,double-precision,scientific-notation

The number you are getting is related to the machine epsilon for the double data type. A double is 64 bits long, with 1 bit for the sign, 11 bits for the exponent, and 52 bits for the mantissa fraction. A double's value is given by 1.mmmmm... * (2^exp) With...