Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix toPrecision (was off by one for fractional inputs) #384

Merged
merged 1 commit into from Jan 24, 2024

Conversation

efergus
Copy link
Contributor

@efergus efergus commented Jan 9, 2024

The toPrecision function was wrong for fractional inputs like 0.222 with small values for precision, for example:

Ex:

toPrecision(0.222, 2) // 0.2

Instead, it should be

toPrecision(0.222, 2) // 0.22

closes #385

Copy link

netlify bot commented Jan 9, 2024

Deploy Preview for colorjs ready!

Name Link
🔨 Latest commit 7434c88
🔍 Latest deploy log https://app.netlify.com/sites/colorjs/deploys/659db134b9fa2900083644f0
😎 Deploy Preview https://deploy-preview-384--colorjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@efergus efergus changed the title Fix toPrecition (was off by one for fractional inputs) Fix toPrecision (was off by one for fractional inputs) Jan 10, 2024
Copy link
Member

@svgeesus svgeesus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@svgeesus svgeesus merged commit 69c1981 into color-js:main Jan 24, 2024
4 checks passed
jgerigmeyer added a commit to oddbird/color.js that referenced this pull request Jan 30, 2024
* main:
  Fix toPrecition (was off by one for fractional inputs) (color-js#384)
  Add the HCT color space (color-js#380)
  Add gamutSpace to ColorSpace
  Add CJS type defs for node16 resolution. (color-js#383)
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.

toPrecision is broken
2 participants