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 rounding error of negative exponents #13

Closed
wants to merge 1 commit into from
Closed

Fix rounding error of negative exponents #13

wants to merge 1 commit into from

Conversation

shunk76
Copy link

@shunk76 shunk76 commented Feb 20, 2020

pow(4, 10 * (0.8 - 1)); expects 0.0625, but return 1.

Maybe,

// dist/functions/_pow.scss
@if $exp < 0 {
    $exp: $exp * -1; //=> 1.9999999999 🤔
    $s: 1;
}

So, 👇

@if $exp < 0 {
    $exp: ceil($exp * -1); //=> 2
    $s: 1;
}

Try this:

$exp: 10 * (0.8 - 1) * -1; //=> 2 ? maybe 1.9999999999
$int: floor($exp); //=> 2 ? but 1
@debug $exp, $int, $exp - $int; //=> 2, 1, 1 😩

@terkel terkel self-requested a review February 28, 2020 07:56
@terkel
Copy link
Owner

terkel commented Feb 29, 2020

@shunk76 I don’t know why, but the test fails…

Pow should calculate negative exponents
  ✗ Expected 0.0625 to equal 0.0625
  Test failed

@shunk76
Copy link
Author

shunk76 commented Mar 6, 2020

OK, thanks !

@shunk76 shunk76 closed this Mar 6, 2020
@shunk76 shunk76 deleted the work branch March 6, 2020 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants