Problems with float

2006-08-14 Thread James Smith
Interesting issue...

I am extracting a price from an XML feed for insertion into our local data.
The price is returned as a simple float value which I can output to screen
just fine.  Unfortunately when I insert the info into the database it gets a
little messed up.

Here are 5 inserted values from a small test run...

19.988
15.99
9.9902
14.99
39.992

As you can see, 2 of them inserted fine but 3 of them got inserted with a
0.002 margin of error.  Does anyone know why this is happening?

FYI: This is going into MSSQL but I get the same problems with MySQL so I
don't think it is a DB issue.

--
Jay

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.10.9/417 - Release Date: 11/08/2006
 


~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:249705
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Problems with float

2006-08-14 Thread Tom Chiverton
On Monday 14 August 2006 12:00, James Smith wrote:
 The price is returned as a simple float value which I can output to screen
 just fine.  Unfortunately when I insert the info into the database it gets
 a little messed up.

Are you performing any arithmetic on this value ?

-- 
Tom Chiverton



This email is sent for and on behalf of Halliwells LLP.

Halliwells LLP is a limited liability partnership registered in England and 
Wales under registered number OC307980 whose registered office address is at St 
James's Court Brown Street Manchester M2 2JF.  A list of members is available 
for inspection at the registered office. Any reference to a partner in relation 
to Halliwells LLP means a member of Halliwells LLP. Regulated by the Law 
Society.

CONFIDENTIALITY

This email is intended only for the use of the addressee named above and may be 
confidential or legally privileged.  If you are not the addressee you must not 
read it and must not use any information contained in nor copy it nor inform 
any person other than Halliwells LLP or the addressee of its existence or 
contents.  If you have received this email in error please delete it and notify 
Halliwells LLP IT Department on 0870 365 8008.

For more information about Halliwells LLP visit www.halliwells.com.


~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:249706
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Problems with float

2006-08-14 Thread Martin Thorpe
I have had problems with floats before, where the calculations were incorrect.  
Wrapping everything with val(number) or evaluate(number) sorted it all out for 
me.

It was all with calculations that the problems were caused though, returning 
incorrect numbers.

cheers
Martin 

Interesting issue...

I am extracting a price from an XML feed for insertion into our local data.
The price is returned as a simple float value which I can output to screen
just fine.  Unfortunately when I insert the info into the database it gets a
little messed up.

Here are 5 inserted values from a small test run...

19.988
15.99
9.9902
14.99
39.992

As you can see, 2 of them inserted fine but 3 of them got inserted with a
0.002 margin of error.  Does anyone know why this is happening?

FYI: This is going into MSSQL but I get the same problems with MySQL so I
don't think it is a DB issue.

--
Jay

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.10.9/417 - Release Date: 11/08/2006

~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:249708
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


RE: Problems with float

2006-08-14 Thread James Smith
No calculations are being done, I am simply grabing the value from an XML
feed and then doing an SQL insert into the DB.

--
Jay 

 -Original Message-
 From: Martin Thorpe [mailto:[EMAIL PROTECTED] 
 Sent: 14 August 2006 12:45
 To: CF-Talk
 Subject: Re: Problems with float
 
 I have had problems with floats before, where the 
 calculations were incorrect.  Wrapping everything with 
 val(number) or evaluate(number) sorted it all out for me.
 
 It was all with calculations that the problems were caused 
 though, returning incorrect numbers.
 
 cheers
 Martin 
 
 Interesting issue...
 
 I am extracting a price from an XML feed for insertion into 
 our local data.
 The price is returned as a simple float value which I can output to 
 screen just fine.  Unfortunately when I insert the info into the 
 database it gets a little messed up.
 
 Here are 5 inserted values from a small test run...
 
 19.988
 15.99
 9.9902
 14.99
 39.992
 
 As you can see, 2 of them inserted fine but 3 of them got 
 inserted with 
 a
 0.002 margin of error.  Does anyone know why 
 this is happening?
 
 FYI: This is going into MSSQL but I get the same problems 
 with MySQL so 
 I don't think it is a DB issue.
 
 --
 Jay
 
 --
 No virus found in this outgoing message.
 Checked by AVG Free Edition.
 Version: 7.1.405 / Virus Database: 268.10.9/417 - Release Date: 
 11/08/2006
 
 

~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:249710
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


RE: Problems with float

2006-08-14 Thread Leon Oosterwijk
Are you storing the data in a float field in the db? Floats are
inherently inaccurate. You should probably use the decimal(x,y) data
type (if you're using SQL server). 

Leon


-Original Message-
From: James Smith [mailto:[EMAIL PROTECTED] 
Sent: Monday, August 14, 2006 7:11 AM
To: CF-Talk
Subject: RE: Problems with float

No calculations are being done, I am simply grabing the value from an
XML feed and then doing an SQL insert into the DB.

--
Jay 

 -Original Message-
 From: Martin Thorpe [mailto:[EMAIL PROTECTED]
 Sent: 14 August 2006 12:45
 To: CF-Talk
 Subject: Re: Problems with float
 
 I have had problems with floats before, where the calculations were 
 incorrect.  Wrapping everything with
 val(number) or evaluate(number) sorted it all out for me.
 
 It was all with calculations that the problems were caused though, 
 returning incorrect numbers.
 
 cheers
 Martin
 
 Interesting issue...
 
 I am extracting a price from an XML feed for insertion into
 our local data.
 The price is returned as a simple float value which I can output to 
 screen just fine.  Unfortunately when I insert the info into the 
 database it gets a little messed up.
 
 Here are 5 inserted values from a small test run...
 
 19.988
 15.99
 9.9902
 14.99
 39.992
 
 As you can see, 2 of them inserted fine but 3 of them got
 inserted with
 a
 0.002 margin of error.  Does anyone know why
 this is happening?
 
 FYI: This is going into MSSQL but I get the same problems
 with MySQL so
 I don't think it is a DB issue.
 
 --
 Jay
 
 --
 No virus found in this outgoing message.
 Checked by AVG Free Edition.
 Version: 7.1.405 / Virus Database: 268.10.9/417 - Release Date: 
 11/08/2006
 
 



~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:249713
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4