FROUND.Q

RISC-V FROUND.Q Instruction Details

Instruction ManualR-type

Round a quad-precision floating-point value to an integral value in the same FP format, without setting NX.

Instruction Syntax

fround.q rd, rs1, rm
Operand Breakdown
rd: destination floating-point register receiving the rounded result in the same format.
rs1: the only source floating-point register; the encoded rs2 field is fixed to 00100 (decimal 4), not a second source floating-point register.
rm: rounding-mode field; rm=111 uses the dynamic frm rounding mode.
ZfaQFP Precision

Instruction Behavior

FROUND.Q rounds the quad-precision floating-point value in f[rs1] to an integral value according to rm, but writes the result back to f[rd] in the same quad-precision floating-point format. The FROUND form does not set the inexact NX flag. A signaling NaN sets NV; quiet NaNs follow the floating-point NaN result rules.

FROUND.Q Decode And Execute Animation

Shows the Zfa + Q-extension quad-precision OP-FP flow: decode fields, read FP operands, perform FROUND semantics, then write rd.

rd
rs1
rm
fround.q
,
,
Execution Context
FLEN=128 / fmt=Q (11)
rounding: RNE nearest-even
fflags: FROUND example leaves fflags clear
31..27
26..25
24..20
19..15
14..12
11..7
6..0
01000
FROUND
11
fmt=Q
00100
rs2=4 (roundToIntegral)
01011
rs1
000
rm
01010
rd
1010011
OP-FP
Execution Data Path
instruction
0x46458553
opcode
1010011 -> OP-FP
funct5/fmt
01000 + Q(11) -> FROUND.Q
rm
000 -> RNE nearest-even
rd/rs
fa0(f10) / fa1(f11) / rs2=00100 (fixed)
read
1.5
FP op
roundToIntegral(1.5, RNE nearest-even) = 2.0
write
fa0(f10) = 2.0; FROUND example leaves fflags clear
Current Step

Fetch: show the 32-bit OP-FP encoding

The word is split as an R-type OP-FP instruction; quad-precision OP-FP instructions use opcode 1010011.

encoding: 0x46458553
syntax : fround.q fa0(f10), fa1(f11), rne
result : fa0(f10) = 2.0; FROUND example leaves fflags clear

This bounded teaching model computes whitelisted finite examples plus zero, infinity, and NaN; FROUND.Q writes the integral value in Q format. Zero and infinity are copied. FROUND does not set NX and sets no exception flags other than NV.

Quad-precision Calculation
rs1
fa1(f11) = 1.5
rs2
ft4(f4) = 0.0
result
roundToIntegral(1.5, RNE nearest-even) = 2.0

This bounded teaching model computes whitelisted finite examples plus zero, infinity, and NaN; FROUND.Q writes the integral value in Q format. Zero and infinity are copied. FROUND does not set NX and sets no exception flags other than NV.

This animation shows only Zfa + Q-extension ISA-visible OP-FP encoding, example numeric results, and fflags relationship; it does not model FPU pipelines, latency, every IEEE 754 corner case, or microarchitecture.

Quick Understanding & Search Notes

FROUND.Q differs from FCVT by output type: FROUND.Q still writes a floating-point register, with the value rounded to an integral value. FROUND deliberately does not report inexact NX.

rm selects the rounding direction, with frm supplying dynamic rounding.
Special values such as zero and infinity follow the Zfa rules; signaling NaNs still set NV.

Common Usage Scenarios

Floating-Point Rounding

Understand this scenario with real code like «fround.q f0, f1, rne # f0 = round(f1), no inexact flag».

Numeric Format Handling

Understand this scenario with real code like «fround.q f0, f1, rne # f0 = round(f1), no inexact flag».

Pre-Use Checklist

Syntax Check
  • rd: destination floating-point register receiving the rounded result in the same format.
  • rs1: the only source floating-point register; the encoded rs2 field is fixed to 00100 (decimal 4), not a second source floating-point register.
  • rm: rounding-mode field; rm=111 uses the dynamic frm rounding mode.
Semantic Check
  • Confirm the floating-point format suffix (.H/.S/.D/.Q) matches the data width.
  • Decide whether software must inspect fflags for NV, DZ, OF, UF, or NX.

Pitfalls / Common Confusions

FROUND does not set NX; use FROUNDNX to set NX when the input differs from the rounded result and is not NaN.
The result is still floating-point, not an integer-register result; use FCVT for an integer result.
rm controls the direction for rounding to an integral value.

FAQ

Does FROUND.Q write an integer register?

No. The result is written to floating-point register f[rd]; the floating-point value is integral.

How does FROUND.Q differ from the other FROUND form?

FROUND does not set NX; FROUNDNX sets NX only when the input differs from the rounded result and is not NaN.