-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Open
Open
Copy link
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsT-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Description
Location (URL)
For floating-point types (including f32 etc.):
For integer types (including u8 etc.):
i32::checked_powi32::overflowing_powi32::powi32::saturating_powi32::strict_powi32::wrapping_pow
Summary
The following is a table of the return value of the exponentiation methods in special cases:
self |
n/exp |
Return value |
|---|---|---|
| x | ±0 | 1 for any x |
| 1 | y | 1 for any y |
| x | 1 | x for any x |
NAN |
y | NAN |
| x | NAN |
NAN |
| ±0 | y | INFINITY or NEG_INFINITY for y an odd integer < 0 |
| ±0 | NEG_INFINITY |
INFINITY |
| ±0 | INFINITY |
+0 |
| ±0 | y | INFINITY for finite y < 0 and not an odd integer |
| ±0 | y | ±0 for y an odd integer > 0 |
| ±0 | y | +0 for finite y > 0 and not an odd integer |
| -1 | INFINITY or NEG_INFINITY |
1 |
| x | INFINITY |
INFINITY for |x| > 1 |
| x | NEG_INFINITY |
+0 for |x| > 1 |
| x | INFINITY |
+0 for |x| < 1 |
| x | NEG_INFINITY |
INFINITY for |x| < 1 |
INFINITY |
y | INFINITY for y > 0 |
INFINITY |
y | +0 for y < 0 |
NEG_INFINITY |
y | (-0).pow(-y) |
| x | y | NAN for finite x < 0 and finite non-integer y |
Some programming language documentation has descriptions similar to this:
math.Powin Gostd.math.powin ZigSystem.Math.Powin .NET
I think this can be expressed as doc comments or doctests. This is primarily intended for floating-point types, but I think some of it can be used for integer types as well.
In particular, in most programming languages, zero to the power of zero (
Metadata
Metadata
Assignees
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsT-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.