![]() |
Does VBA round .5 up or down?
Rounding in VBA doesn't seem to be consistent. Running the following code
shows that 3.825 rounds down to 3.82, and 3.875 rounds up to 3.88. MsgBox ("3.825 rounded = " & Round(3.825, 2) & "; 3.875 rounded = " & Round(3.875, 2)) Is there an explanation for this? |
Does VBA round .5 up or down?
VBA uses "Banker's Rounding" (which I think is a term that MS made up),
to round a 5 in the least significant digit to the nearest *even* number in the next most significant digit. This method is frequently used in science and statistics. See http://support.microsoft.com/kb/196652/EN-US/ In article , pod wrote: Rounding in VBA doesn't seem to be consistent. Running the following code shows that 3.825 rounds down to 3.82, and 3.875 rounds up to 3.88. MsgBox ("3.825 rounded = " & Round(3.825, 2) & "; 3.875 rounded = " & Round(3.875, 2)) Is there an explanation for this? |
All times are GMT +1. The time now is 01:32 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com