+ 1
why -7 / 3 = -3 in ruby ??
puts (-7/3) produce -3
2 Antworten
+ 5
-7/3 = -3
-7.0/3 = -2.333
Great question :)
The rule is that without having the decimal fraction point, ".", all the results are presented in floor function mode, which mathematically is the largest integer smaller than the result:
[x] = max{ n ∈ Z | n<= x }
0
because rule of signs: -/+ = -