Allow rounding option
allowRounding(default:true)With this variable set
true,calc(100% / 3)will output33.33333%(withprecision: 5). If it is setfalseit will remaincalc(100% / 3). Another example withallowRounding: false:calc(900% / 16)will output56.25%withprecision: 5(becausecalc(900% / 16)==56.25%), butcalc(900% / 16)withprecision: 0(becausecalc(900% / 16)!=56%).
By default this option is true and this will result in the same behaviour as we have now. If it's set to false, we prevent for example calc(100% / 3) to be rounded to 33.33333%.
Closes #62
There is no difference here from the current implementation. You can already disable rounding by setting precision to false.
@andyjansson, there is a difference when the allowRounding is set false:
This option allows users to limit the default precision to what's defined in precision, but doesn't round the number if the rounded number isn't equal to the number itself. This may sound a bit vague, so let's demonstrate this with an example:
Let's assume you have configured precision: 5 and allowRounding: false:
-
calc(100% / 3)will outputcalc(100% / 3)becausecalc(100% / 3) != 33.33333% -
calc(100% / 4)will output25%becausecalc(100% / 4) == 25%
What's the advantage? We never have rounded numbers which can cause issues like https://github.com/twbs/bootstrap/pull/27374 and we don't have expressions like calc(100% / 4) that can be simplified.
This option is a bit tricky because it depends on another option, that's why I tried to explain it with examples instead of words.
Please open an issue about it so it can be discussed further.
/cc @MartijnCuppens can we rebase again? :smile: