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

Richard Davey rdavey at gmail.com
Wed Aug 25 08:33:33 CDT 2004


On Wed, 25 Aug 2004 14:03:29 +0100, Liam Delahunty
<liam at megaproducts.co.uk> wrote:

> 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!
> 
> eg,
>   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
> errors?

How are you actually comparing the values? Are you sure they are not
being rounded in some way? (i.e. 1.8 rounding to 2.0 or similar). Post
that piece of the code perhaps?

Cheers,

Rich


More information about the thelist mailing list