Tag Archives: decimal

Compare the performance of the float, double, and decimal data types in C#

A computer’s math coprocessor typically gives the best performance with a particular data type. To see which works best on my system and to learn how big the difference is, I wrote this program to compare the performance of calculations … Continue reading

Posted in performance, variables | Tagged , , , , , , , , , , | 6 Comments

Compare speeds of arithmetic operations in C#

This example compares the speeds of arithmetic operations with different data types. There’s a big difference between the speeds of operations using the decimal data type and the other types, so performing a loop a certain number of time is … Continue reading

Posted in algorithms, calculations, mathematics | Tagged , , , , , , , , , , , , , , , , | Leave a comment

Convert bases decimal, hexadecimal, octal, and binary in C#

It’s easy to convert bases if you use the Convert class’s ToInt64 and ToString methods. For example, the following statement parses the text in the TextBox named source and saves the result in the long variable value. The “16” means … Continue reading

Posted in mathematics, parsing | Tagged , , , , , , , , , , , | 6 Comments

Parse currency values in C#

Converting a decimal value into a currency formatted string is easy. Simply use its ToString method, passing it the parameter “C” as in the following code. txtAny.Text = value.ToString(“C”); Strangely parsing a currency value entered by the user is not … Continue reading

Posted in parsing, syntax | Tagged , , , , , , , , , , | Leave a comment