Article View: comp.databases.ms-access
Article #337Re: Rounding problems with Access
From: Tom van Stiphout
Date: Thu, 15 Jul 1999 00:00
Date: Thu, 15 Jul 1999 00:00
94 lines
3797 bytes
3797 bytes
On Thu, 15 Jul 1999 12:52:44 GMT, "Larry LeBlanc" <larry.leblanc@sympatico.ca> wrote: Check out KB Article Q111781 I usually get ticked off by people who can post to the newsgroup, but can't get back on to check results. However, you were using environmentally safe electrons, which gives you bonus points. -Tom. >Good day, > >Can anyone explain to me why the following source code: > > =================================== > Private Sub Command9_Click() > > Dim Looper As Single > > For Looper = 0 To 1 Step 0.1 > Debug.Print Looper > Stop > Next Looper > > End Sub > =================================== > >leads to the following results: > > =================================== > 0 > 0.1 > 0.2 > 0.3 > 0.4 > 0.5 > 0.6 > 0.7 > 0.8000001 > 0.9000001 > =================================== > >Why is Access having difficulties with such a basic program. I am writing a >complex financial simulations (on the Canadian Mutual Fund Market), and what >I consider basic math is being completely mangled by Access. For example, >when I run the following simplified code: > > =================================== > Dim SharesToPurchase As Long > Dim Bank As Currency > Dim ClosingPrice As Single > > SharesToPurchase = Int(Bank / ClosingPrice) > Debug.Print "Bank Balance Before Transaction = " & Str(Bank) > Debug.Print "Closing Price = " & Str(ClosingPrice) > Debug.Print "Shares To Purchase = " & Str(SharesToPurchase) > Debug.Print "Transaction Amount = " & Str(SharesToPurchase * >ClosingPrice) > Bank = Bank - (SharesToPurchase * ClosingPrice) > Debug.Print "Bank Balance After Transaction = " & Str(Bank) > Stop > =================================== > >I get the following results: > > =================================== > Bank Balance Before Transaction = 1000000 > Closing Price = 15.06 > Shares To Purchase = 66401 > Transaction Amount = 999999.087862968 > Bank Balance After Transaction = .912137031555176 > =================================== > >Does anyone know of a Microsoft KnowledgeBase article that can help me with >this problem? In addition to posting a follow-up to this problem, can you >please e-mail me directly (mailto:larry.leblanc@sympatico.ca) as I cannot >follow this newsgroup. > >TIA, > >Larry >-- >=================================================================== >Larry LeBlanc, CNE-3 >Montreal, Quebec, CANADA >mailto:larry.leblanc@sympatico.ca (flames directed to /dev/null) >------------------------------------------------------------------- >This message was compiled and sent using environmentally friendly >recycled electrons and was not tested on animals. >=================================================================== > >
Technical Details
Message-ID:
<378de7c0.2167046@news.syspac.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<wQkj3.4$PZ3.247@198.235.216.4>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111a5a,73518ce6c7069b00 X-Google-Attributes: gid111a5a,public X-Google-Thread: 1131f0,73518ce6c7069b00 X-Google-Attributes: gid1131f0,public X-Google-Thread: 102b1d,73518ce6c7069b00 X-Google-Attributes: gid102b1d,public X-Google-Thread: ff0ac,73518ce6c7069b00 X-Google-Attributes: gidff0ac,public From: tomvs@syspac.com (Tom van Stiphout) Subject: Re: Rounding problems with Access Date: 1999/07/15 Message-ID: <378de7c0.2167046@news.syspac.com> X-Deja-AN: 501340170 References: <wQkj3.4$PZ3.247@198.235.216.4> X-Trace: news2.randori.com 932048690 204.181.57.29 (Thu, 15 Jul 1999 07:24:50 PDT) Organization: Mach 2 Systems, Inc. NNTP-Posting-Date: Thu, 15 Jul 1999 07:24:50 PDT Newsgroups: comp.databases.ms-access,de.comp.datenbanken.ms-access,es.comp.bd.ms-access,microsoft.public.access.modulesdaovba