Reputation: 83
There are several rounding modes in the IEEE 754 floating point standard, my question is: is the rounding mode selected based on the guard/round/sticky bits or does a programmer specify what mode to use?
Upvotes: 2
Views: 537
Reputation: 80276
The rounding mode is chosen by the programmer. Either the rounding mode is stored in a “control register” inside the FPU, and is changed through a specific (expensive) instruction, or each floating-point instruction has a few bits reserved to indicate what rounding mode it is intended to be executed in.
Either way, the programmer controls the rounding mode that applies each time a floating-point instruction is executed, and the rounding mode influences how the guard/round/sticky bits are interpreted to round the result, not the other way round.
Upvotes: 2