I'm using Visual Studio 2015 on Windows 10, I'm still a new coder, I've just started to learn C#, and while I was in the process, I discovered the Math class and was just having fun with it, till the console outputted: " ∞ "
It's a Console Application
Here's the code:
var k = Math.Sqrt((Math.Pow(Math.Exp(5), Math.E)));
var l = Math.Sqrt((Math.Pow(Math.PI, Math.E)));
Console.WriteLine("number 1 : " + k);
Console.WriteLine("number 2 : " + l);
Console.ReadKey();
var subject = Math.Pow(Math.Sqrt((Math.Pow(Math.PI, Math.E))), Math.Sqrt((Math.Pow(Math.Exp(5), Math.E))));
Console.WriteLine(k + " ^ " + l + " = " + subject);
Console.ReadKey();
//output :
/*number 1 : 893.998923601492
number 2 : 4.73910938029088
893.998923601492 ^ 4.73910938029088 = ∞*/
Why is this happening? using normal calculator the result is: 96985953901866.7
C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...
What is C? C is a general-purpose programming language created by Dennis Ritchie at the Bell Laboratories in 1972. It is a very popular language, despite being old. C is strongly associated with UNIX, as it was developed to write the UNIX operating system.
Compared to other languages—like Java, PHP, or C#—C is a relatively simple language to learn for anyone just starting to learn computer programming because of its limited number of keywords.
Full form of C is “COMPILE”. One thing which was missing in C language was further added to C++ that is 'the concept of CLASSES'.
Because you are doing
var subject = Math.Pow(l, k);
instead of
var subject = Math.Pow(k, l);
You are inverting base with exponent!
And you should really reuse your variables, instead of recalculating everything! (had you reused the variables, the problem would have been more apparent).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With