[Tutor] Integer division Help requested
Danny Yoo
dyoo at hkn.eecs.berkeley.edu
Wed Oct 4 23:11:54 CEST 2006
>> I feel
>> 7/3 should give -2
>>
>> since integer divison returns floor
>
> The floor is the next lowest integer to the float.
> floor(-3.000000001) will be -4
> floor(3.99999999) will be 3
Hi Joseph,
If it helps, draw out the floor function out on a piece of graph paper.
^
|
2| x==O
|
1| x==O
|
<---------x==O------->
|
x==O
|
x==O |
|
V
I'm using the "x==O" to try to graphically draw out the half-open
intervals.
If you believe this diagram, then the results you're seeing from integer
division should make sense.
More information about the Tutor
mailing list