Re: adCurrency problem in ASP
From: Jonathan Dodds (NO_REPLY)
Date: 03/27/05
- Next message: Evertjan.: "Re: adCurrency problem in ASP"
- Previous message: mjkahn: "Re: ASP stops responding"
- In reply to: Evertjan.: "Re: adCurrency problem in ASP"
- Next in thread: Evertjan.: "Re: adCurrency problem in ASP"
- Reply: Evertjan.: "Re: adCurrency problem in ASP"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 27 Mar 2005 14:50:51 -0500
"Evertjan." <exjxw.hannivoort@interxnl.net> wrote in message
news:Xns9626842FB84E3eejj99@194.109.133.29...
> Jonathan Dodds wrote on 27 mrt 2005 in
> microsoft.public.inetserver.asp.general:
>
> > I'm using ADO from an ASP 3.0 page written in JScript to query a
database
> > table in SQL Server 2000. One of the columns in a currency field.
> >
> > Instead of retrieving a value of 1095.60 like I expect, I'm getting
> > 1095.6000000000001 instead.
> >
> [..]
> >
> > Am I doing something wrong here?
>
> Yes you do.
>
> What is wrong is your expectation.
>
> Non integer values are usually stored in a binary format.
> Just like 1/3 cannot be exactly stored in a decimal format,
> many decimal fractions cannot be stored in a binary form,
> without an error in the least significant bit(s).
> The back conversion to decimal will not always result in the same
> error nullified.
>
> So if you want to represent a numberic value with a fixed number of
> decimals, either store it as a integer [in cents, if we are talking
> currency] or have a good rounding off algoritm.
>
> btw: Some Basic interpreters build by Bill Gates around 1984
> used BCD [binary coded decimal] as a standard number coding method.
> There your problem would not arise. VBscript and Jscript do not use BCD.
>
> --
> Evertjan.
> The Netherlands.
> (Replace all crosses with dots in my emailaddress)
>
Why doesn't Query Analyzer display the decimal error? Is it rounding behind
my back?
- Next message: Evertjan.: "Re: adCurrency problem in ASP"
- Previous message: mjkahn: "Re: ASP stops responding"
- In reply to: Evertjan.: "Re: adCurrency problem in ASP"
- Next in thread: Evertjan.: "Re: adCurrency problem in ASP"
- Reply: Evertjan.: "Re: adCurrency problem in ASP"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|