pub struct Math {
pub errno: bool,
pub finite_only: bool,
pub signed_zeros: bool,
pub reciprocal: bool,
pub associative: bool,
pub unsafe_math: bool,
}Expand description
The members of -ffast-math that are licences about what an arithmetic may answer, one field
each, so that a build writing -ffast-math -fno-finite-math-only gets what gcc gives it.
Nothing here folds floating point arithmetic in a function body at any level, so none of these
changes the code this compiler writes. What each one does change is the predefined set: gcc
names each licence it was given with a macro of its own, <math.h> and a numerics library read
those, and a header that configured itself for a licence the other objects were built without is
a program answering two ways. -ftrapping-math is the sixth member and lives in
Options::trapping_math, because it was taken before the rest and it is the one that does
change an answer here.
Fields§
§errno: boolWhether a function in the maths library is taken to set errno, from -fmath-errno. On,
which is gcc’s default on a target whose library does it.
finite_only: boolWhether the program promises there are no NaNs and no infinities, from
-ffinite-math-only.
signed_zeros: boolWhether the sign of a zero is kept, from -fsigned-zeros. On by default.
reciprocal: boolWhether a division may become a multiplication by the reciprocal, from
-freciprocal-math.
associative: boolWhether an addition may be regrouped, from -fassociative-math. gcc drops this with a
warning unless signed zeros and trapping are both off, so what counts is
Math::associative rather than the field.
unsafe_math: bool-funsafe-math-optimizations, which is its own flag as well as the three it turns on.
Implementations§
Source§impl Math
impl Math
Sourcepub fn set_unsafe(&mut self, on: bool) -> bool
pub fn set_unsafe(&mut self, on: bool) -> bool
-funsafe-math-optimizations and its negative, which set or clear the members gcc’s
set_unsafe_math_optimizations_flags does. Trapping is one of them, so it is handed back
for the caller to store where it lives.
Sourcepub fn set_fast(&mut self, on: bool) -> bool
pub fn set_fast(&mut self, on: bool) -> bool
-ffast-math and -fno-fast-math, which are set_fast_math_flags in gcc: the unsafe
group, the maths library’s errno and the promise about NaNs. The value handed back is
trapping, as above.
Sourcepub fn associative(&self, trapping: bool) -> bool
pub fn associative(&self, trapping: bool) -> bool
Whether regrouping survives, which it does only where nothing could tell: a regrouped sum can move a zero’s sign and can raise an exception the original order did not.