itcaptain
asked on
C# Rounding Whole Numbers
I have a question regarding c# and rounding. Given the following equations c# seems to round them differently based on if a decimal is dictated in the whole number. Is there any way to tell C# to output 7.5 regardless of the format of the code?
I am in the process of converting some legacy code and I don’t have the option of ensuring the static values are formatted with “.00”.
I am in the process of converting some legacy code and I don’t have the option of ensuring the static values are formatted with “.00”.
double test = 3000.00 / 400.00;
test = 7.5;
double test2 = 3000 / 400;
test2 = 7;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.