Skip to content

Fix odd rounding errors#19

Open
makenai wants to merge 1 commit intokentor:masterfrom
makenai:master
Open

Fix odd rounding errors#19
makenai wants to merge 1 commit intokentor:masterfrom
makenai:master

Conversation

@makenai
Copy link
Copy Markdown

@makenai makenai commented Jun 4, 2016

I know you're not maintaining this, but thought I'd send this just in case someone else finds it useful. I was finding that the background was jumping around on me in Chrome. It turned out that for very long decimals, it was rendering the numbers as scientific numbers and then concatenating them to 'px' and treating 0.00000000000005 px the same as 5px. This rounds up to a whole pixel value.

Prevent this behavior:

(450 - 449.99999999999994) + 'px' 
"5.684341886080802e-14px"

Prevent this behavior: 
```javascript
(450 - 449.99999999999994) + 'px' 
"5.684341886080802e-14px"
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant