Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Test for fractions of a penny
I'm attempting to write code to determine if the user entered a value
that has a fraction of a cent. Here is my logic dim i as long dim d as double If IsNumeric(.Value) = True And .Value < 0 Then .Value = Abs(.Value) i = CLng(CDbl(.Value) * 100) d = CDbl(.Value) * 100 If Abs(d - i) 0 Then MsgBox "Rounding error detected! Make sure you don't have umbers with values less than 1/100th", vbExclamation End If Else .Value = "" End If It seems to work for most cases however I'd found some specific values that always report "Round error detected!...." Values such as 282.47, 32.41 and 132.70 If I MsgBox i & " " & d the numbers are the same so Abs(d - i) 0 should always be false I don't quite understand what's doing on. Is there a better way to test for fractions of a cent? Eric |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Calc sometimes off by a penny | Excel Worksheet Functions | |||
Exel 2007 penny off | Excel Discussion (Misc queries) | |||
AutoSum lost a penny | Excel Worksheet Functions | |||
My accounting program is a penny off, Why? | Excel Worksheet Functions | |||
In Excel the total is off by a penny. | Excel Worksheet Functions |