java,string,format,exponential

The problem must be somewhere else, because your formatting is correct. I've tried this: public static void main (String[] args) throws java.lang.Exception { double number = 333333333333l*(double)333333333333l; System.out.println(String.format("%.5e",number)); } And the result is 1.11111e+23 ...assuming it is Java. You can check here: https://ideone.com/VubwX7...

javascript,slider,logarithm,exponential

You can start with above method: html part: <input id='digits' type="range" min="-1000" max="1000" value="0" step="100" /> js part: $("#digits").on("input change", function() { var is_negative = this.step < 0; this.step = (is_negative)? (Math.abs(this.step) / 1.025).toFixed(0) : Math.pow(Math.abs(this.step), 1.025).toFixed(0); }); This is not the ONE right decision, it is just the Right...

As you mentioned C++ in the tag, try one of this method: double pow (double base , double exponent); float pow (float base , float exponent); long double pow (long double base, long double exponent); double pow (Type1 base , Type2 exponent); // additional overloads Returns base raised to the...

algorithm,big-o,complexity-theory,exponential

What the entry says is something like this. Suppose the algorithm is exponential with base c, so that for some input of size x, the running time is t ~= cx. Now given a processor twice as fast, with an input just a (I'm calling your constant that) larger, the...

c#,math,regression,logistic-regression,exponential

Some general advice: use linear regression only as basic regression algorithm. Higher Order regressions (polynoms, splines) tend to produce information which is not really based by the data, especially if you have just a handful of data points If you want to model exponential or logarithmic data, then take the...

3/7 is evaluated to 0, since you are dividing two integers, so Math.pow(num, pow) becomes Math.pow(num, 0.0) which is 1.0. Change it to 3.0/7 in order to get a floating point result....

math,volume,equation,exponential

Here's a derivation of the function. All it takes is some algebra. Model and Constraints We want an exponential function of the following form, that takes number between 0 and 1: f(t) = a * bt + c The function must satisfy these constraints you gave: f(0) = 0 =...

algorithm,smoothing,exponential,poisson

First, if you assume that the occurrence rate of the events itself is constant (or that you're only interested in its long-term average), then you can simply estimate it as: λ* = N / (t − t0) where t is the current time, t0 is the...

matlab,equation,numerical-methods,exponential

Here is some code that can find the best solution to your problem, if there is one. In this case, there is no reasonable solution, but defining A by M([4 2]) (for example) does work reasonably well. A = [1 2 3; 3 4 1; 2 4 4] %// the...

You can see this answer : Pseudorandom Number Generator - Exponential Distribution Here the java code public double getNext() { return Math.log(1-rand.nextDouble())/(-lambda); } Have a nice day...

You can use the g format specifier, which chooses between the exponential and the "usual" notation based on the precision, and specify the number of significant digits: >>> "%.3g" % 4.311237638482733e-91 '4.31e-91' If you want to always represent the number in exponential notation use the e format specifier, while f...

Well, you can use the same logarithmic functions here too. Include cmath. In-code . . cout << log(8) / log(3) << endl; . . Output . . . ...3... . . . ...

In case your dataframe is called dfs, you can do the following: dfs[c('Dependent.variable.1','Forecast.Dependent.variable.1')] <- exp(dfs[c('Dependent.variable.1','Forecast.Dependent.variable.1')]) which gives you: X Year Dependent.variable.1 Forecast.Dependent.variable.1 1 1 2009 249371 247288.7 2 2 2010 241131 242907.5 3 3 2011 234678 238603.9 4 4 2012 224285 234376.5 5 5 2013 220377 230224.0 6 6 2014...

Just avoid using `1-pnorm': pnorm(30,lower.tail=FALSE) [1] 4.906714e-198 ...

php,jquery,html,html5,exponential

You should use pow function in php Example: <?php var_dump(pow(2, 8)); // int(256) echo pow(-1, 20); // 1 echo pow(0, 0); // 1 echo pow(-1, 5.5); // PHP >4.0.6 NAN echo pow(-1, 5.5); // PHP <=4.0.6 1.#IND ?> ...

Yes, it is possible to only use addition to do exponentiation. Remember that multiplication is the repetition of addition many times, and that exponentiation is the repetition of multiplication many times. For example, you could write the following function that will exponentiate a number: double exp(long base, long exponent) {...

simulation,distribution,exponential

What you're doing is called a time-step simulation, and can be terribly inefficient. Each tick in your master clock for loop represents a delta-t increment in time, and in each tick you have a laundry list of "did this happen?" possible updates. The larger the time ticks are, the lower...

A couple of comments: i is already supported as the imaginary number in MATLAB. It is superfluous to declare i = sqrt(-1);. Also real is a function in MATLAB. It basically returns the real part of a complex number defined in MATLAB. Do not make this symbolic. By doing this,...

python,numpy,scipy,curve-fitting,exponential

I cleaned up your code and made the time start at 0, what I've done more than once with exponential functions in order to make them work properly: import matplotlib.pyplot as plt import numpy as np from scipy.optimize import curve_fit time, temp = np.loadtxt('test.txt', unpack=True) # Newton cooling law fitting...

c++,qt,calculator,exponential,exp

void MainWindow::on_btnCalculate_clicked() { QString s; int intNum1 = ui->leNum1->text().toInt(); int intNum2 = ui->leNum2->text().toInt(); qreal result = qExp((qreal)intNum1* intNum2); s = QStrimg::number(result); ui->lblCalculate->setText(s); } ...

Here's an idea: constexpr std::array<unsigned long long, 16> LUT = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768 }; ...

php,image,math,zoom,exponential

The problem comes from the fact that you are adding a delta to your scale instead of multiplying it by a constant amount each frame: $currentScale += $deltaScale; An exponential zoom means you increase the zoom by a constant factor (not difference) for a given constant amount of time, so...

c#,wpf,string,number-formatting,exponential

If you also want to make sure it really is a number, not just a string with an 'E' in it, maybe a function like this can be helpful. The logic remains simple. private bool IsExponentialFormat(string str) { double dummy; return (str.Contains("E") || str.Contains("e")) && double.TryParse(str, out dummy); } ...

A dplyr approach: require(dplyr) df <- df %.% group_by(c,d) %.% filter(1:n() <= 250) %.% mutate(weight = 0.06*(0.94)^(seq(249,0,-1))) ...

python,algorithm,numbers,exponential

Some algorithms require raising numbers to very large powers. Algorithms from cryptography in particular come to mind, such as the Diffie-Hellman key exchange. While your algorithm might be fine for most everyday tasks, when you're dealing with exponents that are very large, it becomes unfeasible to use, so exponentiation by...

java,algorithm,random,logarithm,exponential

Is this what you want? I took numbers uniformly distributed over the range formed by the logs of the limits, then used Math.exp to convert back to the actual range. I sorted the result array because your examples showed sorted data. Delete the Arrays.sort call if you don't want that....

python,series,factorial,exponential

Move your sumt variables into your while loop, and then break out of the loop when sumt5 <= 0.00: import decimal def fact(n): if n == 0: return 1 else: return n*(fact(n-1)) x = 1 # Hardcoded for this example, instead of prompting. A = 0 summation = 1.0 while...

No it is not possible, as looking at the documentation double only stores 15 to 16 digits so it will revert to the short format if the number is larger than that. On the other hand ulong is 64 bits and contain a much larger number accurately, and if that...

An important programming tenet: don't over-optimise prematurely. Given that 1 << n will be performed in integer arithmetic which significantly limits the results space, the fastest way would be to precompute them and use a lookup table (e.g. a simple array). For a 64 bit unsigned integral types such a...

c++,while-loop,printf,continue,exponential

I checked the code, and it works fine. As you have pointed out, this error only occurs on command prompt and not on online editors, a possible reason may be your compiler. Which one do you use? Or maybe you could provide some other details. I have attached a...

Do one of the following, Console.WriteLine(s.ToString("N0")); //comma separated Console.WriteLine(s.ToString("F0")); Both works....

How many decimal places you want to show/see, just round it up. The small error arises because of limited number of decimal places of pi are used in calculation.

algorithm,big-o,time-complexity,complexity-theory,exponential

Well, your method is also concrete. You should proceed in the same direction. Currently, I also don't have a better option. 4^n = ((2^2)^n) = (2^2n) = (2^n) * (2^n) > 2^n for all values of n>0. As, (2^n) * (2^n) > O(2^n) . This is because (2^n) * (2^n)...

matlab,numbers,format,exponential

Here's one way. I'm assuming the numbers are positive (otherwise you'd need to deal with the minus sign separately). x = 250; e = floor(log10(x))+1; s1 = sprintf('.%5i', round(x*10^(5-e))); s2 = sprintf('%02d', abs(e)); s = [s1 'E' repmat('+', e>=0) repmat('-', e<0) s2]; The repmat('+', e>=0) repmat('-', e<0) part of the...