Click here to Skip to main content
15,943,335 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
problems with class math function pow when i do 65 ^ 331 return infinity
double xx=65;
double aa=331;

double result =Math.Pow(xx,aa);
//final result is ... infinity 

then i used class BigInteger and return real number but the result is not same windows calculator
windows calculator :

65 ^ 331 =1.1866456424809823888425970808655e+600
class math return infinity and class BigIntger return number not same windows calculator result

why i use the number 65 and 331 because i programming algorithmic must be result final same windows calculator _

double a=65;
double y=331;
double mode_;
double js=17741;
double final_ =power_get(a,y);

double mode_=final % js; //must be result is 530 ?

 private static double power_get(double power, double E)
            double base_pow = power;
            double top_pow =E;
            double exploit_js = base_pow;//2
            double i;
            for (i = 0; i < top_pow - 1; i++)
                exploit_js *= base_pow;
            return exploit_js;

i need way to get a final result for this calculate is= 530;
i know double is limited storage but what ? the variable
type can be solve this and get the result final is =530?
austinbox 7-Dec-13 0:06am    
Well, the data type long does hold bits of a range from -9223372036854775808 to 9223372036854775807
And if you know the number is positive which would work in this case you could increase the range of positive numbers using ulong.

What you observe are the correct valid results. Perhaps all your problem is to get familiar with floating-point numbers, as an approximate computer representation of such concept and mathematical abstraction as real numbers:[^],[^].

Just to note: the theory of real numbers, being a base of calculus, is an extremely deep and complex field of mathematics.

Share this answer
You are aware your code will not compile as is ?

Consider that it might be difficult/impossible to match exactly in C# the internal algorithms and data-structures used by Windows Calc ... unless MS published them.

You could, using the WinAPI Platform Invoke facilities use 'SetParent, and 'MoveWindow, to kind-of "embed" the Win Calculator in your .NET C# app, but I suspect that would be unsatisfactory, and inter-operation with it ... as in reading the contents of the display text-edit window ... is ... tricky.

MS has an example of using 'SendKeys in C# to control the Win Calculator: [^].

The .NET NameSpace System.Windows.Automation is a better way to attempt to inter-operate; see: [^].
Share this answer
Joezer BH 8-Dec-13 4:49am    

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900