How can I calculate 98 raised to the power of exp(13-5) using JavaScript?
Is this the way?
Math.pow(98,Math.exp(8))
How can I calculate 98 raised to the power of exp(13-5) using JavaScript?
Is this the way?
Math.pow(98,Math.exp(8))
When I need to handle large positive numbers that would overflow standard floating point types then I store the numbers as log of the number instead. So instead of calculating 98 to the power of exp(8), I'd calculate exp(8) * log(98) and work with that. I haven't (yet) come across a situation where even that method was inadequate to store the numbers that I needed. However, I have come across several situations where the right answer involves multiplying very very large numbers by very very small numbers, and in that situation using logs as I described has avoided overflows/underflows which would result in the wrong answer.
Update: I suspect this is some kind of homework question relating to how to get round the problem that 98 ^ exp(8) is too big for standard floating point types. In which case, I think my suggestion to use logs comes in handy. For example, to print out the number in C# you could do the following:
double x = Math.Exp(13 - 5) * Math.Log(98); // the number required is exp(x)
int exponent = (int)Math.Floor(x / Math.Log(10));
double absissae = Math.Exp(x - exponent * Math.Log(10));
System.Diagnostics.Trace.WriteLine(absissae.ToString() + " E " + exponent.ToString());
which produces the output
5.77130918514205 E 5935