round Floating Point Round
| Library: | Floating Point Arithmetic |
Behavior
This component rounds the floating-point value on its west input to an integral value and returns that value in the selected floating-point format. The Rounding mode attribute selects the operation.
- Round up
- Returns the smallest integral value greater than or equal to the input.
- Round down
- Returns the greatest integral value less than or equal to the input.
- Round to nearest
- Returns the nearest integral value; a halfway case is rounded toward positive infinity.
- Round to nearest, ties to even
- Returns the nearest integral value; a halfway case is rounded to the even integer.
- Truncate
- Discards the fractional part, rounding toward zero.
Round to nearest and Truncate use a signed 64-bit integer intermediate. Values outside that range, including infinities, are limited to the nearest signed 64-bit endpoint before being encoded in the selected floating-point format. The other three modes preserve infinities.
The ERR output is 1 when the input is NaN and 0 otherwise. An input containing unknown or error bits is converted to NaN. With a NaN input, Round to nearest and Truncate produce zero, while the other modes produce NaN; the result should not be used while ERR is 1.
Pins
- West edge (input, bit width matches Float size)
- The floating-point value to round.
- East edge (output, bit width matches Float size)
- The integral-valued floating-point result.
- South edge (output, bit width 1)
- ERR: 1 if the input is NaN; otherwise 0.
Attributes
- Float size
- The floating-point width of the input and result: 8, 16, 32, or 64 bits.
- Rounding mode
- Selects round up, round down, nearest, nearest with ties to even, or truncate.
Poke Tool Behavior
None.
Text Tool Behavior
None.