On Nov 12, 10:23 am, swapna.munuk...@gmail.com wrote:
I am new to c#.
I am facing a problem with exponential or scientific notification.
When I use math.pow() funciton, if the numbers are big, it returns me
in exponential format.
No, it just returns you a double. The double itself doesn't specify a
textual representation - you need to specify your format when you call
ToString if you want a particular one.
And when I do any arthimatic operations on that, it gives me wrong
results.
For example:
?System.Math.Pow(2,60)
1.152921504606847E+18
?System.Math.Pow(2,60)-1
1.152921504606847E+18
What do you believe to be the problem here? You've gone way beyond the
bounds of double's accurate representation - how did you expect the
results to be differentiated?
How can I solve this problem?
Well, you shouldn't expect double to have more accuracy than it
actually does. If you need accurate representations of numbers this
large, you should probably be using a custom maths library. There are
some 3rd party ones around.
And is there a way to supress exponential notation?
Use the appropriate format specifier.
Jon