View source code
Display the source code in std/math/rounding.d from which this
page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a
Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Module std.math.rounding
This is a submodule of std
.
It contains several functions for rounding floating point numbers.
Functions
Name | Description |
---|---|
ceil(x)
|
Returns the value of x rounded upward to the next integer (toward positive infinity). |
floor(x)
|
Returns the value of x rounded downward to the next integer (toward negative infinity). |
lrint(x)
|
Rounds x to the nearest integer value, using the current rounding mode. |
lround(x)
|
Return the value of x rounded to the nearest integer. |
nearbyint(x)
|
Rounds x to the nearest integer value, using the current rounding mode. |
quantize(val, unit)
|
Round val to a multiple of unit . rfunc specifies the rounding
function to use; by default this is rint , which uses the current
rounding mode.
|
quantize(val, exp)
|
Round val to a multiple of pow(base, exp) . rfunc specifies the
rounding function to use; by default this is rint , which uses the
current rounding mode.
|
rint(x)
|
Rounds x to the nearest integer value, using the current rounding mode. |
rndtol(x)
|
Returns x rounded to a long value using the current rounding mode. If the integer value of x is greater than long.max, the result is indeterminate. |
round(x)
|
Return the value of x rounded to the nearest integer. If the fractional part of x is exactly 0.5, the return value is rounded away from zero. |
trunc(x)
|
Returns the integer portion of x, dropping the fractional portion.
This is also known as "chop" rounding.
pure on all platforms.
|
Authors
Walter Bright, Don Clugston, Conversion of CEPHES math library to D by Iain Buclaw and David Nadlinger
License
Copyright © 1999-2022 by the D Language Foundation | Page generated by ddox.