scientific-notation

How can I print a huge number in Lua without using scientific notation?

柔情痞子 提交于 2019-11-28 12:06:51
I'm dealing with timestamps in Lua showing the number of microseconds since the Epoch (e.g. "1247687475123456"). I would really like to be able to print that number in all its terrible glory, but Lua insists on printing it in scientific notation. I've scoured the available documentation about printing a formatted string, but the only available commands are "Print in scientific notation (%e/%E)" and "Automatically print in scientific notation if the number is very long (%g)". No options seem to be available to print the number in its normal form. I realize that I could write a function that

how to prevent numbers from showing up in scientific notations

若如初见. 提交于 2019-11-28 12:01:47
We have a StreamBuffer class in which we haven't implemented std::fixed operations and I am trying to prevent number showing up in scientific notations. With my below code some numbers are getting shown in scientific notations. We want to avoid doing any allocations so that's why we implemented StreamBuffer class because of performance reason. Below is the code: T value = 0; template<typename U> void process(U& buf, DataOption holder) const { if (holder == DataOption::TYPES) { switch (type_) { case teck::PROC_FLOAT: buf << "{\"float\":" << value << "}"; break; case teck::PROC_DOUBLE: buf << "{

Opposite of Number.toExponential in JS

亡梦爱人 提交于 2019-11-28 11:19:21
I need to get the value of an extremely large number in JavaScript in non-exponential form. Number.toFixed simply returns it in exponential form as a string, which is worse than what I had. This is what Number.toFixed returns: >>> x = 1e+31 1e+31 >>> x.toFixed() "1e+31" Number.toPrecision also does not work: >>> x = 1e+31 1e+31 >>> x.toPrecision( 21 ) "9.99999999999999963590e+30" What I would like is: >>> x = 1e+31 1e+31 >>> x.toNotExponential() "10000000000000000000000000000000" I could write my own parser but I would rather use a native JS method if one exists. Gene Pavlovsky The answer is

How to stop doubles converting to scientific notation when using a stringstream

ⅰ亾dé卋堺 提交于 2019-11-28 10:06:07
I'm making a function to return the number of decimal and whole number digits and am converting the inserted typename number to a string using sstream s. However the number when being converted to a string comes out in scientific notations which is not useful for counting the number of digits are in the normal number. How can I stop this from happening in my function below? enum { DECIMALS = 10, WHOLE_NUMBS = 20, ALL = 30 }; template < typename T > int Numbs_Digits(T numb, int scope) { stringstream ss(stringstream::in | stringstream::out); stringstream ss2(stringstream::in | stringstream::out)

Prevent axes from being in scientific notation (powers of 10) using matplotlib in Python on semilogy plot

时光毁灭记忆、已成空白 提交于 2019-11-28 09:33:25
问题 I've read here (How to prevent numbers being changed to exponential form in Python matplotlib figure) and here (Matplotlib: disable powers of ten in log plot) and tried their solutions to no avail. How can I convert my y-axis to display normal decimal numbers instead of scientific notation? Note this is Python 3.5.2. Here's my code: #Imports: import matplotlib.pyplot as plt possible_chars = 94 max_length = 8 pw_possibilities = [] for num_chars in range(1, max_length+1): pw_possibilities

Scientific notation colorbar in matplotlib

余生长醉 提交于 2019-11-28 03:59:19
I am trying to put a colorbar to my image using matplotlib. The issue comes when I try to force the ticklabels to be written in scientific notation. How can I force the scientific notation (ie, 1x10^0, 2x10^0, ..., 1x10^2, and so on) in the ticks of the color bar? Example, let's create and plot and image with its color bar: import matplotlib as plot import numpy as np img = np.random.randn(300,300) myplot = plt.imshow(img) plt.colorbar(myplot) plt.show() When I do this, I get the following image: However, I would like to see the ticklabels in scientific notation... Is there any one line

How do I get to haskell to output numbers NOT in scientific notation?

时光毁灭记忆、已成空白 提交于 2019-11-28 02:40:10
问题 I have a some items that I want to partition in to a number of buckets, such that each bucket is some fraction larger than the last. items = 500 chunks = 5 increment = 0.20 {- find the proportions -} sizes = take chunks (iterate (+increment) 1) base = sum sizes / items buckets = map (base *) sizes main = print buckets I'm sure there is a mathematically more elegant way to do this, but that's not my question. The end step is always printing out in scientific notation. How do I get plain

Python - fixed exponent in scientific notation?

ぐ巨炮叔叔 提交于 2019-11-27 22:16:24
Consider the following Python snippet: for ix in [0.02, 0.2, 2, 20, 200, 2000]: iss=str(ix) + "e9" isf=float(iss) print(iss + "\t=> " + ("%04.03e" % isf ) + " (" + str(isf) + ")") It generates the following output: 0.02e9 => 2.000e+07 (20000000.0) 0.2e9 => 2.000e+08 (200000000.0) 2e9 => 2.000e+09 (2000000000.0) 20e9 => 2.000e+10 (20000000000.0) 200e9 => 2.000e+11 (2e+11) 2000e9 => 2.000e+12 (2e+12) My question is - is it possible to "go back" somehow? That is: 2.000e+07 => 0.02e9 2.000e+08 => 0.2e9 2.000e+09 => 2e9 2.000e+10 => 20e9 2.000e+11 => 200e9 2.000e+12 => 2000e9 ... I'd specify I want

How to make C++ cout not use scientific notation

家住魔仙堡 提交于 2019-11-27 12:59:31
double x = 1500; for(int k = 0; k<10 ; k++){ double t = 0; for(int i=0; i<12; i++){ t += x * 0.0675; x += x * 0.0675; } cout<<"Bas ana: "<<x<<"\tSon faiz: "<<t<<"\tSon ana: "<<x+t<<endl; } this the output Bas ana: 3284.78 Son faiz: 1784.78 Son ana: 5069.55 Bas ana: 7193.17 Son faiz: 3908.4 Son ana: 11101.6 Bas ana: 15752 Son faiz: 8558.8 Son ana: 24310.8 Bas ana: 34494.5 Son faiz: 18742.5 Son ana: 53237 Bas ana: 75537.8 Son faiz: 41043.3 Son ana: 116581 Bas ana: 165417 Son faiz: 89878.7 Son ana: 255295 Bas ana: 362238 Son faiz: 196821 Son ana: 559059 Bas ana: 793246 Son faiz: 431009 Son ana: 1

How can I convert numbers into scientific notation?

拟墨画扇 提交于 2019-11-27 09:24:14
I want to make a function that takes an entered value and converts it to scientific notation (N x 10^a) I've tried many different things, but I can't seem to get it right. Example: I enter 200. The converter converts it to 2 x 10^2 You can do something like this: a = 200 a.toExponential(); //output 2e+2 fiddle: http://jsfiddle.net/Q8avJ/9/ At some point I wanted to use the coefficient and the exponent as numbers. If you want to do that, you can use toExponential function, split the string and convert the items of the array to numbers. In the following snippet I assign the numbers to the