W3C home > Mailing lists > Public > public-css-archive@w3.org > July 2019

[csswg-drafts] [css-values] Are sqrt(X) and pow(X, .5) equivalent for −∞? (#4157)

From: Oriol Brufau via GitHub <sysbot+gh@w3.org>
Date: Mon, 29 Jul 2019 16:59:37 +0000
To: public-css-archive@w3.org
Message-ID: <issues.opened-474157286-1564419576-sysbot+gh@w3.org>
Loirooriol has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-values] Are sqrt(X) and pow(X, .5) equivalent for −∞? ==
From https://drafts.csswg.org/css-values/#funcdef-sqrt

> `sqrt(X)` and `pow(X, .5)` are equivalent; `sqrt()` is a common enough function that it is provided as a convenience.

According to https://drafts.csswg.org/css-values/#exponent-infinities,

> In `sqrt(A)`, if A is +∞, the result is +∞. If A is less than 0, the result is NaN.
> In `pow(A, B)`, if A is negative, B must be an integer, or else the result is NaN.

so it seems both `sqrt(−∞)` and `pow(−∞, 0.5)` should be NaN.

But there is also a table for infinity values which says that `pow(−∞, 0.5)` should be +∞.

> A is -∞, B is > 0: result is -∞ if B is an odd integer, +∞ otherwise 

And there is this note:

> All of these behaviors are intended to match the "standard" definitions of these functions as implemented by most programming languages, in particular as implemented in JS.

But `sqrt(X)` and `pow(X, .5)` are not equivalent in JS:

```js
Math.pow(-Infinity, 0.5) // +Infinity
Math.sqrt(-Infinity) // NaN
```


Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/4157 using your GitHub account
Received on Monday, 29 July 2019 16:59:39 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:41:50 UTC