1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00

No longer perform division using integer division if only integers are used.

If you want integer-based division you should now do the following instead:
floor(14/5)
which will return 2 instead of 2.8.
This commit is contained in:
Chris Eppstein 2008-10-13 11:44:20 -07:00
parent 00e953df48
commit 689bb9e683
2 changed files with 4 additions and 2 deletions

View file

@ -129,8 +129,10 @@ module Sass::Script
other = other.coerce(numerator_units, denominator_units)
end
end
# avoid integer division
value = (:/ == operation) ? this.value.to_f : this.value
result = value.send(operation, other.value)
result = this.value.send(operation, other.value)
if result.is_a?(Numeric)
Number.new(result, *compute_units(this, other, operation))
else # Boolean op

View file

@ -7,7 +7,7 @@
#times { num-num: 7; num-col: #7496b8; col-num: #092345; col-col: #243648; }
#div { num-num: 3.333; num-num2: 3; col-num: #092345; col-col: #0b0d0f; comp: 1px; }
#div { num-num: 3.333; num-num2: 3.333; col-num: #092345; col-col: #0b0d0f; comp: 1px; }
#mod { num-num: 2; col-col: #0f0e05; col-num: #020001; }