std.math

  • Contains the elementary mathematical functions (powers, roots,
  • and trigonometric functions), and low-level floating-point operations.
  • Mathematical special functions are available in std.mathspecial. *

Category Members
Constants constants, E

constants, PI constants, PI_2 constants, PI_4 constants, M_1_PI constants, M_2_PI constants, M_2_SQRTPI constants, LN10 constants, LN2 constants, LOG2 constants, LOG2E constants, LOG2T constants, LOG10E constants, SQRT2 constants, SQRT1_2

Algebraic algebraic, abs

algebraic, fabs algebraic, sqrt algebraic, cbrt algebraic, hypot algebraic, poly algebraic, nextPow2 algebraic, truncPow2

Trigonometry trigonometry, sin

trigonometry, cos trigonometry, tan trigonometry, asin trigonometry, acos trigonometry, atan trigonometry, atan2 trigonometry, sinh trigonometry, cosh trigonometry, tanh trigonometry, asinh trigonometry, acosh trigonometry, atanh

Rounding rounding, ceil

rounding, floor rounding, round rounding, lround rounding, trunc rounding, rint rounding, lrint rounding, nearbyint rounding, rndtol rounding, quantize

Exponentiation & Logarithms exponential, pow

exponential, powmod exponential, exp exponential, exp2 exponential, expm1 exponential, ldexp exponential, frexp exponential, log exponential, log2 exponential, log10 exponential, logb exponential, ilogb exponential, log1p exponential, scalbn

Remainder remainder, fmod

remainder, modf remainder, remainder remainder, remquo

Floating-point operations operations, approxEqual

operations, feqrel operations, fdim operations, fmax operations, fmin operations, fma operations, isClose operations, nextDown operations, nextUp operations, nextafter operations, NaN operations, getNaNPayload operations, cmp

Introspection traits, isFinite

traits, isIdentical traits, isInfinity traits, isNaN traits, isNormal traits, isSubnormal traits, signbit traits, sgn traits, copysign traits, isPowerOf2

Hardware Control hardware, IeeeFlags

hardware, ieeeFlags hardware, resetIeeeFlags hardware, FloatingPointControl

  • The functionality closely follows the IEEE754-2008 standard for
  • floating-point arithmetic, including the use of camelCase names rather
  • than C99-style lower case names. All of these functions behave correctly
  • when presented with an infinity or NaN.
  • The following IEEE 'real' formats are currently supported:
    • 64 bit Big-endian 'double' (eg PowerPC)
    • 128 bit Big-endian 'quadruple' (eg SPARC)
    • 64 bit Little-endian 'double' (eg x86-SSE2)
    • 80 bit Little-endian, with implied bit 'real80' (eg x87, Itanium)
    • 128 bit Little-endian 'quadruple' (not implemented on any known processor!)
    • Non-IEEE 128 bit Big-endian 'doubledouble' (eg PowerPC) has partial support
  • Unlike C, there is no global 'errno' variable. Consequently, almost all of
  • these functions are pure nothrow. *

Functions 1

fnT ieeeMean(T)(const T x, const T y) @trusted pure nothrow @nogc