Instruction
FRNDINT
Rounds ST(0) to an integral value in the rounding mode of the x87 control word.
- Extensions
- Forms
- 1 (1 Legacy)
- Data
- Intel XED v2026.08.23
FRNDINT rounds ST(0) to an integral value in the direction that the control word’s RC selects, and keeps it as a floating-point number in ST(0). PC does not apply. Where FISTP stores an integer of 16, 32 or 64 bits and fails on what does not fit, FRNDINT has nothing to overflow: every number of 2^63 or more in magnitude is an integer already and comes back unchanged.
Where compilers use it
With RC as C programs keep it, to nearest, FRNDINT is rintl: GCC 14
at -O2 compiles rintl(x) on a long double to a bare frndint.
For floorl, ceill and truncl it stores the control word with
FNSTCW, loads a copy with RC set to down, up or toward
zero with FLDCW, runs FRNDINT and loads the saved word
back, all inline. nearbyintl stays a call of the library unless
-ffast-math is given, because it must not raise the inexact
exception that FRNDINT raises. roundl, whose ties go away from zero
as no RC does, is a call too; with -ffast-math GCC adds 0.5 to |x|,
rounds down and restores the sign. Clang 23 calls the library for all
of them. For doubles in SSE registers, SSE4.1’s
ROUNDSD takes the direction from its immediate and
can suppress the inexact exception.
The edges
- Ties to nearest go to the even integer: 2.5 gave 2, -2.5 gave -2 and 1.5 gave 2, the last with C1 set because it was rounded up.
- A changed value raises PE; an integer, a zero or an infinity comes back unchanged without it.
- The sign survives a result of zero: -0.1 to nearest and -0.5 rounded up gave -0.
- A denormal sets DE and PE: rounded up, the smallest gave 1.
- An SNaN or an unsupported encoding is invalid: IE, and with it masked the QNaN indefinite.
Cost
AMD’s Zen 5 guide lists FRNDINT as one macro-op, of which a core
starts one per cycle, unlike the microcoded transcendental
instructions; the FLDCW pair around it for floorl is microcoded.
Forms
| Instruction | Encoding | Requires |
|---|---|---|
FRNDINT
FRNDINT | D9 FC | FPU |
Operation
What the forms do, in pseudocode that our tests run against results recorded on real processors. How to read.
if empty(st0):
underflow() # IE, SF, C1 = 0
st0 = INDEFINITE
else:
st0 = round(st0) # to an integral value by RC; PE when
# it changes, C1 = 1 if rounded up
c0 = c2 = c3 = UNDEFINEDRun on AMD Zen 5 (EPYC 9645): 27 cases.
Operands
| Operand | Kind | Action |
|---|---|---|
FRNDINT | ||
ST(0) | implicit | read, write |
x87 status word | implicit | write |
Flags
| C0 | C1 | C2 | C3 |
|---|---|---|---|
| All forms | |||
| U | M | U | U |
Attributes
What else XED records about the forms. How to read.
- All forms
- may abort a TSX transaction
CPUID and processors
Each form belongs to an XED ISA set. A form can be used when the processor reports every CPUID bit of one of its ISA set's alternatives.
| ISA set | CPUID | Processors |
|---|---|---|
X87 | FPU | Every x86-64 processor in XED’s model and Zen 3 to Zen 6 |
More x87 instructions
Sources
- Intel XED v2026.08.23 (commit
0bcb6237345c): forms, encodings, operands, flags, exception classes, attributes, ISA sets, CPUID bits and chip model. - The CPU data of x86-64.net: Zen 3 to Zen 6, from GCC’s
-marchfeature sets and AMD’s Processor Programming References, which the page of each processor cites. - Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 2 (325383-093, September 2026): Volume 2A, page 3-372 (FRNDINT)
- Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 1 (253665-093, September 2026)
- AMD64 Architecture Programmer's Manual, Volume 5: 64-Bit Media and x87 Floating-Point Instructions (26569, rev. 3.16, November 2021), Wayback Machine copy of AMD's PDF
- Software Optimization Guide for the AMD Zen5 Microarchitecture (58455, rev. 1.00, August 2024), Wayback Machine copy of AMD's ZIP
The tables are derived from Intel XED, Copyright Intel Corporation, licensed under the Apache License 2.0; x86-64.net converted and reformatted them. The text is our own.