C
Curious
Hi,
I have a double number and need to convert it to an int. Unfortunately
it simply drops the digit(s) after the decimal point. For example:
int requiredShares = (int)(1230.98);
The value of requiredShares is 1230. This is not right. The correct
number should be 1231 because that's the closest integer to 1230.98.
In summary, what I want is to round up to 1 if it's greater than .5
and round down to 0 if it's less than .5.
Anyone can tell me if there's any .NET utility that does what I want?
I have a double number and need to convert it to an int. Unfortunately
it simply drops the digit(s) after the decimal point. For example:
int requiredShares = (int)(1230.98);
The value of requiredShares is 1230. This is not right. The correct
number should be 1231 because that's the closest integer to 1230.98.
In summary, what I want is to round up to 1 if it's greater than .5
and round down to 0 if it's less than .5.
Anyone can tell me if there's any .NET utility that does what I want?