In message <[EMAIL PROTECTED]>
, Gordon Stewart <[EMAIL PROTECTED]> writes
>Hi there, I've come accross a situation, where I am subracting amounts
>from each other - it SHOULD come to whole cents, but im getting
>strange results :-
>
>CODE :-
>
>echo "MIN MAX '$min'$max'<BR>\n";
>if($max-$min<0.02){
>echo ($max-$min)."<BR>\n";
>
>
>(Basically i want to know if its less than 2 cents difference)
>
>What I get on the screen is :-
>
>MIN MAX '5864.51'5864.53'
>0.0199999999995
>
>Now - according tomy maths - 5864.51 subtract 5864.53 should be two cents..
>
>not 1.999999995 cents..

Do you know what the Turing Test is?  You have just passed!  <G>

>Is there a single command at the top of my script to 'round' the
>figures to the nearest two decimal places / cent? (or after each
>calculation ?)

Can't you use
if($max-$min<0.019){  ?

-- 
Pete Clark

Andalucia in Sunny Southern Spain
http://www.hotcosta.com/comm_1.htm



Community email addresses:
  Post message: [email protected]
  Subscribe:    [EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-list 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-list/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to