Re: Subtraction Giving an incorrect value

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



1.907348635E-07 is 1.907348635 time 10 to the minus 7th power (i.e.
0.0000001907348635). As you can see, this is almost zero. The problem is
that floating point numbers aren't handled perfectly, these tends to be a
round-off error. There are some data types that get handle this problem
better, but if you don't specify, the floating point numbers get treated as
Single or Double, which each have this problem. Currency and Decimal don't
because of the way they handle floating point numbers is different. You can
use the Currency data type even if the value isn't going to be currency, but
it does limit you to four decimal places. There is no Decimal data type for
VBA, so to use Decimal data types, you have to use Variants and the CDec()
function as you assign the value to the variant. The other option is to
round off the result to the number of decimals you need. In this case, if
you rounded to one decimal, the result would then be zero.

--
Wayne Morgan
MS Access MVP


"Ann" <Ann@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:62251596-1C7D-45CC-9640-8E2CE1F55C0B@xxxxxxxxxxxxxxxx
>I have a control called PTO Carryover that returns 5.8. I also have an if
> statement (named Carryover) that returns the same value, 5.8. The
> statement
> is =Sum(IIf([PTO Type] Like "Carryover",[Paid Time Off],"0")). These
> values
> are correct and I can see both of them on my report but when I subtract
> Carryover from PTO Carryover (5.8 - 5.8) I get 1.907348635E-07.
>
> Can anyone tell me what is happening? I've tried so many different ways
> to
> get this to come out to 0 but I always get 1.907348635E-07.
>
> Thanks in advance.


.



Relevant Pages

  • Re: Packed decimal arithmetic in C
    ... With floating point, you can't specify how ... >> many decimals to consider during arithmetic, ... applications that track currency and need to do so exactly. ... A scaled integer consists of two values: ...
    (comp.os.vms)
  • RE: Packed decimal arithmetic in C
    ... >many decimals to ... >> I once used double precision floating point in exactly that manner. ... >applications that track currency and need to do so exactly. ... >A scaled integer meets the requirement of exactness. ...
    (comp.os.vms)
  • Re: Extra decimals in Word report from Access
    ... The data types are all set to currency. ... So far I have checked the number formats in the database, ... showing currency and either no decimals or 2 decimals. ...
    (microsoft.public.access.externaldata)
  • Re: Currency or Double for currency values
    ... Tim Zych wrote: ... > viable candidates: Currency and Double. ... > Currency doesn't have the floating point problem that double has. ... MS Access was designed to high perform on Currency data types. ...
    (microsoft.public.access.tablesdbdesign)
  • Re: The fate of Packed-Decimal (was: Error with COMP-3
    ... Do they use floating point, ... 64-bit binary integer with four assumed decimals. ...
    (comp.lang.cobol)