[llvm-dev] Misleading documentation on FP to integer conversion instructions?

Steve (Numerics) Canon via llvm-dev llvm-dev at lists.llvm.org
Fri Sep 4 12:40:44 PDT 2020


> On Sep 4, 2020, at 2:40 PM, Neil Nelson via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
>> If fptosi takes 0.9 -> 0, then that is not 'rounding' in any sense I'm aware of (IEEE754 or otherwise). 
>> Rounding (in the IEE754 sense) determines how a number is converted when it is halfway between two
>> candidate results.  (see round(), ceil(), floor()).

Rounding in the IEEE 754 sense is simply an algorithm to choose one of the two closest values from some set. It does not only concern how halfway cases are handled. There are a number of rounding attributes defined by IEEE 754:

- round to nearest, ties to even (default rounding)
- round to nearest, ties away from zero (only for decimal)
- round to nearest, ties toward zero (used only for augmented addition)
- round up
- round down
- round toward zero

The last of these is the rounding mode under discussion on this thread. Note that the first three have to specify how halfway cases are handled (“ties to …”), but the latter three do not (because the result is constant across the interval between any two values, so there is not change at “halfway”).

– Steve
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200904/29e5528b/attachment.html>


More information about the llvm-dev mailing list