From: john_b_andrews@... (John Andrews) Date: 2003-07-30T11:36:50+09:00 Subject: Re: -3 / 10 = -1 ?! Thanks to Rudolf and Mark for answering my question. I don't know what version of Perl you are both using, but my Perl (5.6.1) on Linux *does* truncate to zero, agreeing with C. Here is the Perl program: use integer; $a = -3; $b = 100; $c = $a / $b; $d = $a % $b; print $c, "\n"; print $d, "\n"; Here is the output: 0 -3 The same program in Ruby gives: -1 97 Thanks, JA john_b_andrews@yahoo.com (John Andrews) wrote in message news:... > Why does this program: > > print -3 / 10, "\n" > > print -1? > > If I underflow a negative int in C, I get zero. > > If I underflow a negative integer in Perl (using "use integer"), > I get zero. > > Why does Ruby give me -1? > > This behavior is not described (in any place I can find) in > the pickaxe book. > > Thanks, > > JA