in reply to Re: Coping with decimals
in thread Coping with decimals

Be also careful if you have negative numbers...

e.g. $X = 1, $Y = 7, $Z = 5

Then:

($X-$Y) = -6, so $calc = ($X-$Y)/$Z = -1.2

but $phase = $calc - int $calc = -1.2 -1 = -2.2, which is not what you wanted...

--------------------------------
An idea is not responsible for the people who believe in it...

Replies are listed 'Best First'.
Re^3: Coping with decimals
by Zaxo (Archbishop) on Jun 02, 2005 at 22:39 UTC

    Did you try it?

    $ perl -e'my ($X,$Y,$Z)=(1,7,5);my $c=($X-$Y)/$Z;print $c-int$c, $/' -0.2 $
    That may not be what's wanted, either.

    After Compline,
    Zaxo