[thelist] PHP type and value match, but value comparssion fails.

Liam Delahunty liam at megaproducts.co.uk
Wed Aug 25 08:03:29 CDT 2004

I've a weird old problem, in my ecommerce application (onlinesales) I've 
added the facility to say "x items ($sold_by) at y cost ($unit_price)", 
so the shop can have say 3 whatsits at 1.20 (total price is therefore 3.60).

Just for error checking I want to check that the total price is equal to 
the unit_price * sold_by. However, I've noticed that some prices, 
despite being 'the same', always error!

  3 units X 0.5 = 1.5, works
  3 units X 0.6 = 1.8, fails...

So, what gives? How can I check these values, and what is causing the 

I've written out a table of the errors (this was done using arrays, so I 
guess there could be different errors here than when using form input, 
but on random checking it's been right so far.)

Here's the table of results:

Here's an input form for testing:	

The code is

Kind regards, Liam Delahunty, Mega Products Ltd
12 Bury Place, London WC1A 2JL Fax: +44(0)871 224 7891
http://www.megaproducts.co.uk/ Internet Design & Development

More information about the thelist mailing list