in reply to Rounding without int() or printf()
sub trunc { my $r = shift; return 0 if ! $r; my $s = $r + $r/abs($r); return $r % $s; } sub grr { my ($q, $d) = @_; return int( $q/$d); }
And honestly, any language that implements a round function invisibly inplements a numerical truncate like "int()" if it doesn't do it explicitly. For instance, to pick a random language say "Perl" =), the '%' modulus forces both of it's arguments to int's before using them.
--
$you = new YOU;
honk() if $you->love(perl)
|
|---|