Re: Ok, why is this happening...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi 

I admit not gone trough all of your code, but mostly this happens when mixing 
the string concatenation operator (.) with the addition (+) or substraction 
(-) operator.

HTH

With kind regards

Andy

On Tuesday 19 July 2005 19:26, John Nichel wrote:
> Chris Boget wrote:
> >>Chris Boget wrote:
> >><snip>
> >>
> >>>echo "if( $originalNet != $calculatedNet ) = " . ( (int)$originalNet !==
> >>>(int)$calculatedNet ) . "<br>\n";
> >>
> >></snip>
> >>Change this to echo out what you're comparing...
> >>echo "if( ". (int)$originalNet ." != ". (int)$calculatedNet ." ) = " . (
> >>(int)$originalNet !== (int)$calculatedNet ) . "<br>\n";
> >>That'll show what numbers is actually trying to match.
> >
> > Ok, then that begs the following questions:
> >
> > If I don't cast any of the values, why do they display as being
> > identicle? Additionally, why does every IF check fail in that case?
>
> There's some freaky math going on there or something.  I added a couple
> of other echos in to see and for some reason it seems to be losing
> single digit value (subtracting, rounding down, I don't know).
>
> $calculatedGross  = $originalNet + ( $originalNet * $commissionPct * 0.01
> );
>
> echo ( "Gross : " . (int)$calculatedGross ." = ". $originalNet ." + ( ".
> $originalNet ." * ". $commissionPct ." *.01 )<br />\n" );
>
> $calculatedNet    = $calculatedGross / ( 1 + ( $commissionPct * 0.01 ));
>
> echo ( "Net : " . (int)$calculatedNet." = " . (int)$calculatedGross . "
> / ( 1 + ( " . $commissionPct . " * .01 ) )<br />\n" );
>
> --
> John C. Nichel
> ÜberGeek
> KegWorks.com
> 716.856.9675
> john@xxxxxxxxxxxx

-- 
Registered Linux User Number 379093
   Cockroaches and socialites are the only things that can 
   stay up all night and eat anything.
					    Herb Caen
--
-- --BEGIN GEEK CODE BLOCK-----
Version: 3.1
GAT/O/>E$ d-(---)>+ s:(+)>: a--(-)>? C++++$(+++) UL++++>++++$ P-(+)>++
L+++>++++$ E---(-)@ W+++>+++$ !N@ o? !K? W--(---) !O !M- V-- PS++(+++)
PE--(-) Y+ PGP++(+++) t+(++) 5-- X++ R*(+)@ !tv b-() DI(+) D+(+++) G(+)
e>++++$@ h++(*) r-->++ y--()>++++
-- ---END GEEK CODE BLOCK------
--
Check out these few php utilities that I released
 under the GPL2 and that are meant for use with a 
 php cli binary:
 
 http://www.vlaamse-kern.com/sas/
--

--

Attachment: pgpCDLVPWL3VP.pgp
Description: PGP signature


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux