Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Rounding Errors
Hello all!
I have a rounding issue. I have numbers that are stored in an array a singles. I want to round them to 1 decimal place "00.0". The way usually round is like this: Sub test() MsgBox (Int(50.599 * 10) * 0.1 & " " & 50.6) End Sub But try this yourselves and you will see that the message box says 50. 50.6. Does anyone know a better method of accuratly rounding -- Message posted from http://www.ExcelForum.com |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Rounding Errors
Sub test()
MsgBox Round(50.599, 1) MsgBox CLng(50.599 * 10) / 10 End Sub HTH. Best wishes Harald "animal1881 " skrev i melding ... Hello all! I have a rounding issue. I have numbers that are stored in an array as singles. I want to round them to 1 decimal place "00.0". The way I usually round is like this: Sub test() MsgBox (Int(50.599 * 10) * 0.1 & " " & 50.6) End Sub But try this yourselves and you will see that the message box says 50.5 50.6. Does anyone know a better method of accuratly rounding? --- Message posted from http://www.ExcelForum.com/ |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Rounding Errors
Check XL VBA help for the Int function and you will see why the
software works as intended. -- Regards, Tushar Mehta www.tushar-mehta.com Excel, PowerPoint, and VBA add-ins, tutorials Custom MS Office productivity solutions In article , animal1881 says... Hello all! I have a rounding issue. I have numbers that are stored in an array as singles. I want to round them to 1 decimal place "00.0". The way I usually round is like this: Sub test() MsgBox (Int(50.599 * 10) * 0.1 & " " & 50.6) End Sub But try this yourselves and you will see that the message box says 50.5 50.6. Does anyone know a better method of accuratly rounding? --- Message posted from http://www.ExcelForum.com/ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Rounding Errors in 2007 | Excel Worksheet Functions | |||
Decimal rounding causing addition errors | Excel Discussion (Misc queries) | |||
Compensating for Excel rounding errors | Excel Discussion (Misc queries) | |||
Rounding Errors Help | Excel Discussion (Misc queries) | |||
Unwanted Rounding Errors | Excel Programming |