A Arjen Oct 16, 2005 #1 Hi, How can I round down? See this sample: 5 / 3 = 1.67 Now I want the answer/value 1. Thanks!
A Anders Borum Oct 16, 2005 #2 Hello! How can I round down? See this sample: 5 / 3 = 1.67 Now I want the answer/value 1. Click to expand... You can use the Math.Floor() method. double integerResult = Math.Floor(1.67);
Hello! How can I round down? See this sample: 5 / 3 = 1.67 Now I want the answer/value 1. Click to expand... You can use the Math.Floor() method. double integerResult = Math.Floor(1.67);
P Peter Rilling Oct 16, 2005 #3 I think if you do integer calculations, that happens automatically. Or just cast it to an integer.
J Jon Skeet [C# MVP] Oct 16, 2005 #4 Arjen said: How can I round down? See this sample: 5 / 3 = 1.67 Now I want the answer/value 1. Click to expand... Integer division in C# is always rounded towards zero. If that's all you need, just do the division with integer operands. If you need actual rounding *down* (even when the result is negative) you probably want Math.Floor.
Arjen said: How can I round down? See this sample: 5 / 3 = 1.67 Now I want the answer/value 1. Click to expand... Integer division in C# is always rounded towards zero. If that's all you need, just do the division with integer operands. If you need actual rounding *down* (even when the result is negative) you probably want Math.Floor.