Hi,
I am trying to build a simple calculator to get x^y, I have found that the '^' symbol is not used in C# and I have to use 'Math.Pow' instead.

I have a form with 2 text boxes for input, an rtf box for output and a button for activating the function.

Here is my button function code:-

void Button1Click(object sender, EventArgs e)
		{
	string text1 = Box1.Text;
	string text2 = Box2.Text;
        int num1 = int.Parse(text1);
        int num2 = int.Parse(text2);
        Output.Text = Convert.ToString(System.Math.Pow(Convert.ToDouble(num1), Convert.ToDouble(num2))); 
		}

It all works fine but what I really need is to be able to display the exact number that is output, for example, 10^26 outputs as 1E+26.

My RTF box is very large, has word wrap set to true and has vertical scrollbars.

Any help would be appreciated.

Cheers..,

K

The ToString method defaults to the standard format for these kind of things. You can pass in a format of your own here. Or are you looking to get a grasp on bignums?
EDIT: I forgot: welcome on this site:)

The ToString method defaults to the standard format for these kind of things. You can pass in a format of your own here. Or are you looking to get a grasp on bignums?
EDIT: I forgot: welcome on this site:)

Hi, thanks for the welcome.

Yes I am trying to return the full number, I have had a quick look around the web and found reference to 'BigNum' but can't fathom how to use it.

Someone else was having this problem and it was explained that computers can only be precise up to 53 binary digits and that is why the output of 10^26 is shown as 1e26.

Any help with implementing BigNum would be very appreciated.

Cheers..,

K

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.