Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Correct pow() for mpf's to be consistent with mpfr/float's - #690

Merged
skirpichev merged 1 commit into
mpmath:masterfrom
skirpichev:nan-and-pow
May 10, 2023
Merged

skirpichev merged 1 commit into
mpmath:masterfrom
skirpichev:nan-and-pow

Conversation

@skirpichev

@skirpichev skirpichev commented Apr 20, 2023

Copy link
Copy Markdown
Collaborator

Before nan's were handled differently than described in the IEEE 754 standard. Now, as for float's or gmpy2.mpfr's:

  • pow(1, y) returns 1 for any y, even a nan
  • pow(x, 0) returns 1 for any x, even a nan

Closes #516

See also:
https://en.cppreference.com/w/c/numeric/math/pow
https://www.mpfr.org/mpfr-current/mpfr.html#index-mpfr_005fpow
https://docs.python.org/3/library/math.html#math.pow

Before nan's were handled differently than described in
the IEEE 754 standard.  Now, as for float's or gmpy2.mpfr's:
  * pow(1, y) returns 1 for any y, even a nan
  * pow(x, 0) returns 1 for any x, even a nan

Closes mpmath#516

See also:
https://en.cppreference.com/w/c/numeric/math/pow
https://www.mpfr.org/mpfr-current/mpfr.html#index-mpfr_005fpow
https://docs.python.org/3/library/math.html#math.pow
@skirpichev
skirpichev merged commit 6390a47 into mpmath:master May 10, 2023
@skirpichev
skirpichev deleted the nan-and-pow branch May 10, 2023 05:47
@skirpichev skirpichev added this to the 1.4 milestone May 9, 2025
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.

mpf arithmetics with inf or nan are inconsistent with python float

1 participant