D
Language
Phobos
Comparisons
object
std
std.base64
std.boxer
std.compiler
std.conv
std.ctype
std.date
std.file
std.format
std.gc
std.intrinsic
std.math
std.md5
std.mmfile
std.openrj
std.outbuffer
std.path
std.process
std.random
std.recls
std.regexp
std.socket
std.socketstream
std.stdint
std.stdio
std.cstream
std.stream
std.string
std.system
std.thread
std.uri
std.utf
std.zip
std.zlib
std.windows
std.linux
std.c
std.c.stdio
std.c.windows
std.c.linux
|
std.math
- const real E;
-
e
- const real LOG2T;
-
log210
- const real LOG2E;
-
log2e
- const real LOG2;
-
log102
- const real LOG10E;
-
log10e
- const real LN2;
-
ln 2
- const real LN10;
-
ln 10
- const real PI;
-
π
- const real PI_2;
-
π / 2
- const real PI_4;
-
π / 4
- const real M_1_PI;
-
1 / π
- const real M_2_PI;
-
2 / π
- const real M_2_SQRTPI;
-
2 / √π
- const real SQRT2;
-
√2
- const real SQRT1_2;
-
√½
- real cos(real x);
-
Returns cosine of x. x is in radians.
Special Values
x | cos(x) | invalid?
| NAN | NAN | yes
| ±∞ | NAN | yes
|
- real sin(real x);
-
Returns sine of x. x is in radians.
Special Values
x | sin(x) | invalid?
| NAN | NAN | yes
| ±0.0 | ±0.0 | no
| ±∞ | NAN | yes
|
- real tan(real x);
-
Returns tangent of x. x is in radians.
Special Values
x | tan(x) | invalid?
| NAN | NAN | yes
| ±0.0 | ±0.0 | no
| ±∞ | NAN | yes
|
- real ldexp(real n,int exp);
-
Compute n * 2exp
References: frexp
- float sqrt(float x);
double sqrt(double x);
real sqrt(real x);
-
Compute square root of x.
Special Values
x | sqrt(x) | invalid?
|
-0.0 | -0.0 | no
|
<0.0 | NAN | yes
|
+∞ | +∞ | no
|
- real cbrt(real x);
-
Cube root.
- real expm1(real x);
-
Calculates the value of the natural logarithm base (e)
raised to the power of x, minus 1.
For very small x, expm1(x) is more accurate
than exp(x)-1.
Special Values
x | ex-1
| ±0.0 | ±0.0
| +∞ | +∞
| -∞ | -1.0
|
- real log(real x);
-
Calculate the natural logarithm of x.
Special Values
x | log(x) | divide by 0? | invalid?
|
±0.0 | -∞ | yes | no
|
< 0.0 | NAN | no | yes
|
+∞ | +∞ | no | no
|
- real log10(real x);
-
Calculate the base-10 logarithm of x.
Special Values
x | log10(x) | divide by 0? | invalid?
|
±0.0 | -∞ | yes | no
|
< 0.0 | NAN | no | yes
|
+∞ | +∞ | no | no
|
- real log1p(real x);
-
Calculates the natural logarithm of 1 + x.
For very small x, log1p(x) will be more accurate than
log(1 + x).
Special Values
x | log1p(x) | divide by 0? | invalid?
|
±0.0 | ±0.0 | no | no
|
-1.0 | -∞ | yes | no
|
<-1.0 | NAN | no | yes
|
+∞ | -∞ | no | no
|
- int isnan(real e);
-
Is number a nan?
- int isfinite(real e);
-
Is number finite?
- int isnormal(float f);
int isnormal(double d);
int isnormal(real e);
-
Is number normalized?
- int issubnormal(float f);
int issubnormal(double d);
int issubnormal(real e);
-
Is number subnormal? (Also called "denormal".)
Subnormals have a 0 exponent and a 0 most significant mantissa bit.
- int isinf(real e);
-
Is number infinity?
- int signbit(real e);
-
Get sign bit.
- real copysign(real to,real from);
-
Copy sign.
- real hypot(real x,real y);
-
Calculates the length of the
hypotenuse of a right-angled triangle with sides of length x and y.
The hypotenuse is the value of the square root of
the sums of the squares of x and y:
sqrt(x² + y²)
Note that hypot(x, y), hypot(y, x) and
hypot(x, -y) are equivalent.
Special Values
x | y | hypot(x, y) | invalid?
|
x | ±0.0 | |x| | no
|
±∞ | y | +∞ | no
|
±∞ | NAN | +∞ | no
|
- real frexp(real value,out int exp);
-
Separate floating point value into significand and exponent.
Returns: - Calculate and return x and exp such that
value =x*2exp and
.5 <= |x| < 1.0
x has same sign as value.
Special values
value | returns | exp
|
±0.0 | ±0.0 | 0
|
+∞ | +∞ | int.max
|
-∞ | -∞ | int.min
|
±NAN | ±NAN | int.min
|
- real pow(real x,uint n);
real pow(real x,int n);
-
Fast integral powers.
- int feqrel(real x,real y);
-
To what precision is x equal to y?
Returns: the number of mantissa bits which are equal in x and y.
eg, 0x1.F8p+60 and 0x1.F1p+60 are equal to 5 bits of precision.
Special values
x | y | feqrel(x, y)
|
x | x | real.mant_dig
|
x | >= 2*x | 0
|
x | <= x/2 | 0
|
NAN | any | 0
|
any | NAN | 0
|
|