- From: Oriol Brufau via GitHub <sysbot+gh@w3.org>
- Date: Wed, 18 Oct 2023 18:37:56 +0000
- To: public-css-archive@w3.org
> This is undefined for negative numbers It's not. `(-1)³ = -1`, thus `∛(-1) = -1` and `∛(-x) = ∛(-1 * x) = ∛(-1) * ∛(x) = - ∛(x)`. Sure, for complex numbers there are 3 possible cubic roots of `-1`, and the principal one is not real, but for real numbers it's properly defined. > JavaScript's `Math.cbrt()` actually does do a sign-matched cube root Sure, because that's what's expected for an odd root. Even roots have no real solution for negative numbers, so `Math.sqrt(-1)` is `NaN`. See https://en.wikipedia.org/wiki/Nth_root#Definition_and_notation > Every positive [real number](https://en.wikipedia.org/wiki/Real_number) x has a single positive nth root [...] > For even values of n, positive numbers also have a negative nth root, while negative numbers do not have a real nth root. For odd values of n, every negative number x has a real negative nth root. > I was using a different implementation which doesn't I guess you were using something like `Math.pow(x, 1/3)`, which is not a cubic root. Floating-point numbers can't represent `1 / 3` exactly. -- GitHub Notification of comment by Loirooriol Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/9477#issuecomment-1769114210 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Wednesday, 18 October 2023 18:37:58 UTC