Is there any functions that controls rounding mode of vcvt_s32_f32 intrinsic? I want to use round toward even instead of round toward negative infinity.
Thanks.
Is there any functions that controls rounding mode of vcvt_s32_f32 intrinsic? I want to use round toward even instead of round toward negative infinity.
Thanks.
Copyright © 2021 Jogjafile Inc.
No, you can't change the rounding mode.
NEON is designed for performance rather than precision, and thus is restricted compared to VFP. Unlike VFP, it's not a full IEEE 754 implementation, and is hardwired to certain settings - quoting from the ARM ARM:
The specific case of floating-point to integer conversion is slightly different in that the behaviour of the
VCVT
instruction in this case (for both VFP and NEON) is to ignore the selected rounding mode and always round towards zero. TheVCVTR
instruction which does use the selected rounding mode is only available in VFP.The ARMv8 architecture introduced a whole bunch of rounding and conversion instructions for using specific rounding modes, but I suspect that's not much help in this particular case. If you want to do conversions under a different rounding mode on ARMv7 and earlier, you'll either have to use VFP (if available) or some bit-hacking to implement it manually.
* The ARM ARM uses IEEE 754-1985 terminology, so more precisely this is round to nearest, ties to even