![]() |
|
[C#] C# Math (Decimals) [Intermediate Level Tutorial] - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [C#] C# Math (Decimals) [Intermediate Level Tutorial] (/showthread.php?tid=755350) |
C# Math (Decimals) [Intermediate Level Tutorial] - Pulser - Oct 20, 2010 Math In C# Intro: When working with multiplying, dividing, subtracting, numbers from textBox's, you must always parse it. If you do not know how to do this, please see my parsing tutorial. When working with decimals in C# "45.5235" you must use a floating point or a double. The difference between the two is this: Float is a floating point on the end, it can hold up to 7 digits. (32 bit) Double can have up to 16 digits. (64 bit) Getting Started: Create two textbox's, and a button. Inside of the button, insert the following: Code double num1 = double.Parse(textBox1.Text);The first line creates a new double variable, and parses the value from the first textbox. The second line creates a new double variable, and parses the value from the second textbox. The third line sets up another double variable, that adds the first two number. Finally, the last line displays the answer. If you want to do something other than add you need to use one of the other mathematical operators: Code + AddsSpoiler (Click to View) Conclusion: Calculating in C# can be used for so many different things. Whether its balancing your check book, finding out how much money you will make in a year, or calculating packets! Code: [IMG]http://i54.[censored].com/6yz9zp.jpg[/IMG] Code private void button4_Click(object sender, EventArgs e)Also, I do not recommend reusing variable names, I just did it to be lazy! * - RoXaN - Nov 12, 2010 nice work but no comment here yet i just start reading one by one i like read ur all tut its really nice thanks for good work sharing here its easy to understand now * - HotN - Nov 12, 2010 "Intermediate Level Tutorial" i'm thinking it's more of a beginer's tutorial. "Intermediate Level Tutorial" would include most of the common number variables, int, float, double, byte, and so on... and how they react with eachother... like... how Code int num = 100;yea just my opinion, its a beginer's tutorial. * - Pulser - Nov 12, 2010 (Nov 12, 2010 04:32 PM)RoXaN Wrote: nice work but no comment here yet i just start reading one by one i like read ur all tut its really nice thanks for good work sharing here its easy to understand now Thanks :D! I was planning on making more if they really did help people. |