question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow rounding option

See original GitHub issue

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 output calc(100% / 3) because calc(100% / 3) != 33.33333%
  • calc(100% / 4) will output 25% because calc(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.

PR: https://github.com/postcss/postcss-calc/pull/61

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
MartijnCuppenscommented, Mar 28, 2019

precision: 'safe' would still need some kind of precision. Lets say for some reason the generated value would be: 15.35153465435186437435513 (and this is the exact number, no numbers after the last 3). That’s a pretty long number, probably something you don’t want. This is why I split precision & allowRounding.

0reactions
alexander-akaitcommented, Mar 27, 2019

@MartijnCuppens Maybe we can do better:

- precision: false - disable precision
- precision: 5 - 5 characters
- precision: 'safe' - as you want in this issue

?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Set rounding precision - Microsoft Support
Force the value of numbers to the rounding precision that is displayed by using the “Precision as displayed” option.
Read more >
ROUNDED Option - Micro Focus
The arithmetic statements allow for the ROUNDED phrase to be optionally specified. The results of an arithmetic statement depend on whether this phrase...
Read more >
Formatting using the Rounding Function - Webucator
The syntax is simply Round (x) , with x being the numeric or currency field to be rounded. Here are some examples of...
Read more >
Rounding Option - Caseware
The Rounding Option dialog enables you to specify program settings for expressing numeric values. This option only applies to Connector linkages created ...
Read more >
Rounding in Power Query – The default rounding mode and ...
Let 's say I have a set of numbers that I want to round to two decimal places. ... If we use the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found