@setFloatMode
@setFloatMode
@setFloatMode(comptime mode: FloatMode) void
Changes the current scope’s rules about how floating point operations are defined.
Strict(default) - Floating point operations follow strict IEEE compliance.-
Optimized- Floating point operations may do all of the following:- Assume the arguments and result are not NaN. Optimizations are required to retain defined behavior over NaNs, but the value of the result is undefined.
- Assume the arguments and result are not +/-Inf. Optimizations are required to retain defined behavior over +/-Inf, but the value of the result is undefined.
- Treat the sign of a zero argument or result as insignificant.
- Use the reciprocal of an argument rather than perform division.
- Perform floating-point contraction (e.g. fusing a multiply followed by an addition into a fused multiply-add).
- Perform algebraically equivalent transformations that may change results in floating point (e.g. reassociate).
This is equivalent to -ffast-math in GCC.
The floating point mode is inherited by child scopes, and can be overridden in any scope. You can set the floating point mode in a struct or module scope by using a comptime block.
FloatMode can be found with @import("std").builtin.FloatMode.
See also:
- Floating Point Operations
