in reply to Re^2: Opinion: where Perl5 wasn't attractive for me
in thread Opinion: where Perl5 wasn't attractive for me

rsFalse:

Rather than $num = ($x - $x % $y) / $y, why not use $num = int $x / $y? I agree that having to use the former would be a bit troublesome. When you mentioned integer division in the OP, I couldn't figure out exactly what was so troublesome about using int. Seeing this, I'm thinking that maybe you're just not aware of it.

Update: I forgot to mention, perl has the sqrt function.

...roboticus

When your only tool is a hammer, all problems look like your thumb.

Replies are listed 'Best First'.
Re^4: Opinion: where Perl5 wasn't attractive for me
by rsFalse (Chaplain) on Nov 20, 2014 at 13:01 UTC
    Yes, I forgot about that :( . But now I tried and it makes a little different results with negatives:
    $/ = " "; $y = 2; while($x = <DATA>){ chop $x; print $num = ($x - $x % $y) / $y xor print " " xor print $num = int $x / $y xor print "\n" } __DATA__ -3 -2 -1 0 1 2 3
    Output: -2 -1 -1 -1 -1 0 0 0 0 0 1 1 1 1
    Yes. I like that Perl has sqrt.

    UPDATE: seems that my approach was not int_div, but floor.