As you have doubtless noted, there’s no standard way to do this (for that matter, there’s no standard definition of “flush to zero”, nor any requirement that hardware implement it). So all of the means of doing this are platform-specific. To add a few more to the list, since this is a useful reference:
OSX / Intel:
fesetenv(_FE_DFL_DISABLE_SSE_DENORMS_ENV)
. Note that this only effects arithmetic done infloat
ordouble
, which is done using SSE2 (hence the name);long double
arithmetic is performed using the legacy x87 instructions, which do not support flushing.iOS / arm: On 32-bit ARM under iOS, flush-to-zero is the default mode. You can turn it off for VFP instructions (but not for NEON) by clearing the
__fpscr_flush_to_zero
bit in afenv_t
object and installing that environment withfesetenv( )
.iOS / arm64:
fesetenv(_FE_DFL_DISABLE_DENORMS_ENV)
.