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

Specify behavior of Math.pow #1952

Closed
ghost opened this issue Mar 2, 2012 · 4 comments
Closed

Specify behavior of Math.pow #1952

ghost opened this issue Mar 2, 2012 · 4 comments
Assignees
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.

Comments

@ghost
Copy link

ghost commented Mar 2, 2012

Library doc needs to specify the behavior of Math.pow, both for doubles and integers. In the absence of documentation Dart attempts to implement behavior defined in ECMA-262 15.8.2.13.

@lrhn
Copy link
Member

lrhn commented Jun 3, 2013

The ES5 standard is pretty arbitrary. It doesn't match any of the three power functions in IEEE-754-2008.
I think we should just use the IEEE pow function:

For the pow function (integral exponents get special treatment):
 pow(x, ±0) is 1 for any x (even a zero, quiet NaN, or infinity)
 pow(±0, y) is ±∞ and signals the divideByZero exception for y an odd integer <0
 pow(±0, −∞) is +∞ with no exception
 pow(±0, +∞) is +0 with no exception
 pow(±0, y) is +∞ and signals the divideByZero exception for finite y<0 and not an odd integer
 pow(±0, y) is ±0 for finite y>0 an odd integer
 pow(±0, y) is +0 for finite y>0 and not an odd integer
 pow(−1, ±∞) is 1 with no exception
 pow(+1, y) is 1 for any y (even a quiet NaN)
 pow(x, y) signals the invalid operation exception for finite x<0 and finite non-integer y.

where the exception of the last line is handled by returning NaN.

This matches ECMAScript Math.pow except for the two next-to-last cases (-1 ** [-]Infinity, 1 ** anything), and it's likely to have an efficient implementation in native libraries.


cc @floitschG.
Set owner to @lrhn.

@floitschG
Copy link
Contributor

Sounds good to me.
If I read this correctly we will guarantee an integer result for x:int, y:int and y>= 0. For all other input we return a double.

@lrhn
Copy link
Member

lrhn commented Aug 21, 2013

Pow is now documented. It matches the cases above, and specifies some more special cases.
VM matches documentation, dart2js may not (it wasn't running lib/math tests at all).

@lrhn
Copy link
Member

lrhn commented Aug 21, 2013

Added Fixed label.

@ghost ghost added Type-Defect area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. labels Aug 21, 2013
@ghost ghost assigned lrhn Aug 21, 2013
copybara-service bot pushed a commit that referenced this issue Feb 13, 2023
…, http_parser, pub_semver, shelf, term_glyph, test, typed_data, webdev

Revisions updated by `dart tools/rev_sdk_deps.dart`.

args (https://github.com/dart-lang/args/compare/bd3ac85..b08471e):
  b08471e  2023-02-09  Sigurd Meldgaard  Suggest command based on aliases (#235)

bazel_worker (https://github.com/dart-lang/bazel_worker/compare/1124692..53871c5):
  53871c5  2023-02-09  Kevin Moore  Migrate to dart_flutter_team_lints, cleanup (#69)

benchmark_harness (https://github.com/dart-lang/benchmark_harness/compare/b1efcf7..a6a0891):
  a6a0891  2023-02-09  Kevin Moore  Require Dart 2.19, update lints to dart_flutter_team_lints (#84)

dartdoc (https://github.com/dart-lang/dartdoc/compare/494a6be..3931595):
  39315954  2023-02-13  Devon Carew  enable additional lints (#3336)
  a52639e7  2023-02-10  Sam Rawlins  Use markdown 7 (#3332)

glob (https://github.com/dart-lang/glob/compare/a828420..f378dc8):
  f378dc8  2023-02-13  Kevin Moore  Update to dart_flutter_team_lints, also cleaned up markdown (#71)

http (https://github.com/dart-lang/http/compare/8386923..f4b365e):
  f4b365e  2023-02-07  Sigurd Meldgaard  Remove dependency on package:path (#865)

http_parser (https://github.com/dart-lang/http_parser/compare/1c0c17a..b3b283b):
  b3b283b  2023-02-08  Kevin Moore  Bump min SDK to 2.17 (#69)

pub_semver (https://github.com/dart-lang/pub_semver/compare/e9c600c..c0e6ea7):
  c0e6ea7  2023-02-12  Devon Carew  Update CHANGELOG.md (#81)
  0d62000  2023-02-12  Kevin Moore  Fix new type error, use dart_flutter_team_lints (#80)

shelf (https://github.com/dart-lang/shelf/compare/9d1fb8a..707c8b2):
  707c8b2  2023-02-07  Kevin Moore  move to pkg:dart_flutter_team_lints (#330)

term_glyph (https://github.com/dart-lang/term_glyph/compare/520784d..d275a8f):
  d275a8f  2023-02-12  Kevin Moore  Fix CI, update lints (#34)

test (https://github.com/dart-lang/test/compare/da7c667..b5e70db):
  b5e70db5  2023-02-10  Jacob MacDonald  Add notes about versioning and publishing to CONTRIBUTING.md (#1929)
  2773daa6  2023-02-09  Jacob MacDonald  update changelog version in test to use ## (#1926)
  9e3072e1  2023-02-09  Danny Tuppeny  Handle absolute paths on Windows (#1923)
  07380027  2023-02-09  Nicholas Shahan  Fix typo in migration doc (#1924)
  f49fc16a  2023-02-09  Kevin Moore  Add auto-publish configuration (#1922)
  5bf28959  2023-02-08  Nate Bosch  Add link to file issue on README (#1921)
  ef81f471  2023-02-08  Nate Bosch  Fix directory name for issue templates (#1920)
  f3bfda9d  2023-02-08  Nate Bosch  Add issue templates (#1919)
  a80f4fd0  2023-02-08  Devon Carew  Refactor top level and package README files (#1918)
  0f4558fe  2023-02-07  Nate Bosch  Prepare to publish test_core and test (#1917)
  39f498c8  2023-02-06  Nate Bosch  Minor readme improvements (#1913)
  2cb07a3f  2023-02-06  Nate Bosch  Rename matches to matchesPattern, accept Pattern (#1907)
  ba6fb1c9  2023-02-06  Jacob MacDonald  Support running tests by absolute file: uri (#1893)
  ffeaec66  2023-02-06  Nate Bosch  Take Condition for async nesting expectations (#1896)
  cdd8c395  2023-02-06  Daniel Chevalier  update vm_service to support 11.0.0 (#1910)
  f2d97bf2  2023-02-06  Nate Bosch  Expand the doc comment for Context (#1902)

typed_data (https://github.com/dart-lang/typed_data/compare/6fbbd95..f858046):
  f858046  2023-02-12  Kevin Moore  fix ci, update analysis options (#61)

webdev (https://github.com/dart-lang/webdev/compare/6255c85..0bae2be):
  0bae2be  2023-02-10  Elliott Brooks (she/her)  Fix lifeline connection logic (#1952)
  4a41cf9  2023-02-10  Anna Gringauze  Support records (#1919)
  d6229e3  2023-02-09  Anna Gringauze  Fix failure on getting a list with out of range offset (#1947)
  f1b15e8  2023-02-09  Anna Gringauze  Fix incorrect list element count (#1944)
  fff4865  2023-02-09  Elliott Brooks (she/her)  Add missing IDs to inspector panel (#1946)
  47287e3  2023-02-08  Elliott Brooks (she/her)  [MV3 Debug Extension] Extension sets the `ide` query parameter for the DevTools URI (#1943)
  1136d51  2023-02-08  Elliott Brooks (she/her)  Catch exceptions in unawaited `Futures` (#1938)
  2cad786  2023-02-07  Anna Gringauze  Cleanup getObject logic for handling offsets and counts (#1936)
  b399e94  2023-02-06  Elliott Brooks (she/her)  Pull out `dart:io`-dependent functions from`/src/utilities/shared.dart` into
`/src/utilities/server.dart` (#1942)

Change-Id: I64bdc5485665ca4c13a331ae7a6c77b1cd3208d8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282802
Commit-Queue: Devon Carew <[email protected]>
Auto-Submit: Devon Carew <[email protected]>
Reviewed-by: Konstantin Shcheglov <[email protected]>
copybara-service bot pushed a commit that referenced this issue Mar 14, 2023
Revisions updated by `dart tools/rev_sdk_deps.dart`.

dartdoc (https://github.com/dart-lang/dartdoc/compare/98fa859..7fde7a4):
  7fde7a4d  2023-03-13  dependabot[bot]  Bump github/codeql-action from 2.2.5 to 2.2.6 (#3363)

http (https://github.com/dart-lang/http/compare/805a147..74f9d3d):
  74f9d3d  2023-03-09  Brian Quinlan  Add conformances test that verify that the Client works in Isolates (#889)
  ee03604  2023-03-09  Brian Quinlan  Add a flag to allow the default Client to be tree shaken away. (#868)
  2039fb3  2023-03-09  Brian Quinlan  Fix a reference count race with forwarded delegates. (#888)

matcher (https://github.com/dart-lang/matcher/compare/c1a0704..985e4ef):
  985e4ef  2023-03-10  Sigurd Meldgaard  Improve mismatch description of `contains` (#206)
  5bc765d  2023-03-09  Nate Bosch  Copy expect and async matchers from test package (#210)

shelf (https://github.com/dart-lang/shelf/compare/e3cfe79..9a792b4):
  9a792b4  2023-03-13  Kevin Moore  Update format for latest v3 SDK (#340)
  c8094b7  2023-03-13  Kevin Moore  Update no-response.yml - once a day (#339)

test (https://github.com/dart-lang/test/compare/3ba78f1..0e5c028):
  0e5c028d  2023-03-10  Nate Bosch  Only use environment variable for chrome (#1970)
  0b08d704  2023-03-08  Nate Bosch  Add a hooks_testing library (#1952)
  aacee2c7  2023-03-08  Nate Bosch  Retry filesystem deletes (#1965)

webdev (https://github.com/dart-lang/webdev/compare/cfe9753..49013b8):
  49013b8  2023-03-09  Elliott Brooks (she/her)  [MV3 Debug Extension] Fix authentication issue for the Dart Debug Extension (#2026)
  c8d4439  2023-03-09  Elliott Brooks (she/her)  Support `Set` inspection in DWDS (#2024)
  442639d  2023-03-08  Elliott Brooks (she/her)  Handle unexpected extension debugger disconnection events without crashing app (#2021)

yaml_edit (https://github.com/dart-lang/yaml_edit/compare/6abc42a..fbc5cb3):
  fbc5cb3  2023-03-09  Kevin Moore  Require Dart 2.19, update to latest lints
  c9e82f0  2023-03-09  Mohamed Ishad  Fix YamlEditor.update method leaving trailing spaces at eol (#42)

Change-Id: Idc785347448e6a56e26d9d46b3666440d59c22de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/288801
Auto-Submit: Devon Carew <[email protected]>
Reviewed-by: Konstantin Shcheglov <[email protected]>
Commit-Queue: Konstantin Shcheglov <[email protected]>
copybara-service bot pushed a commit that referenced this issue Mar 14, 2023
…edit"

This reverts commit fcb8f80.

Reason for revert: google3 roll failure

Original change's description:
> [deps] rev dartdoc, http, matcher, shelf, test, webdev, yaml_edit
>
> Revisions updated by `dart tools/rev_sdk_deps.dart`.
>
> dartdoc (https://github.com/dart-lang/dartdoc/compare/98fa859..7fde7a4):
>   7fde7a4d  2023-03-13  dependabot[bot]  Bump github/codeql-action from 2.2.5 to 2.2.6 (#3363)
>
> http (https://github.com/dart-lang/http/compare/805a147..74f9d3d):
>   74f9d3d  2023-03-09  Brian Quinlan  Add conformances test that verify that the Client works in Isolates (#889)
>   ee03604  2023-03-09  Brian Quinlan  Add a flag to allow the default Client to be tree shaken away. (#868)
>   2039fb3  2023-03-09  Brian Quinlan  Fix a reference count race with forwarded delegates. (#888)
>
> matcher (https://github.com/dart-lang/matcher/compare/c1a0704..985e4ef):
>   985e4ef  2023-03-10  Sigurd Meldgaard  Improve mismatch description of `contains` (#206)
>   5bc765d  2023-03-09  Nate Bosch  Copy expect and async matchers from test package (#210)
>
> shelf (https://github.com/dart-lang/shelf/compare/e3cfe79..9a792b4):
>   9a792b4  2023-03-13  Kevin Moore  Update format for latest v3 SDK (#340)
>   c8094b7  2023-03-13  Kevin Moore  Update no-response.yml - once a day (#339)
>
> test (https://github.com/dart-lang/test/compare/3ba78f1..0e5c028):
>   0e5c028d  2023-03-10  Nate Bosch  Only use environment variable for chrome (#1970)
>   0b08d704  2023-03-08  Nate Bosch  Add a hooks_testing library (#1952)
>   aacee2c7  2023-03-08  Nate Bosch  Retry filesystem deletes (#1965)
>
> webdev (https://github.com/dart-lang/webdev/compare/cfe9753..49013b8):
>   49013b8  2023-03-09  Elliott Brooks (she/her)  [MV3 Debug Extension] Fix authentication issue for the Dart Debug Extension (#2026)
>   c8d4439  2023-03-09  Elliott Brooks (she/her)  Support `Set` inspection in DWDS (#2024)
>   442639d  2023-03-08  Elliott Brooks (she/her)  Handle unexpected extension debugger disconnection events without crashing app (#2021)
>
> yaml_edit (https://github.com/dart-lang/yaml_edit/compare/6abc42a..fbc5cb3):
>   fbc5cb3  2023-03-09  Kevin Moore  Require Dart 2.19, update to latest lints
>   c9e82f0  2023-03-09  Mohamed Ishad  Fix YamlEditor.update method leaving trailing spaces at eol (#42)
>
> Change-Id: Idc785347448e6a56e26d9d46b3666440d59c22de
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/288801
> Auto-Submit: Devon Carew <[email protected]>
> Reviewed-by: Konstantin Shcheglov <[email protected]>
> Commit-Queue: Konstantin Shcheglov <[email protected]>

Change-Id: If7dd2027f4b6ead777eaf1b3cf7561d4dced4095
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/288802
Auto-Submit: Devon Carew <[email protected]>
Bot-Commit: Rubber Stamper <[email protected]>
Commit-Queue: Rubber Stamper <[email protected]>
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.
Projects
None yet
Development

No branches or pull requests

2 participants