I do some numerical calculations, and I often had problems with floating point calculations when using GCC. For my current purpose, I don't care too much about the real accuracy of the results, but I want this proprietary property:
no matter where the same code is in my program, when it runs on SAME inputs, I want it to produce GAME outputs.
How can I get GCC to do this? And specifically, what is the behavior of -fast-math and various -O optimization?
I heard that GCC can try to be smart and sometimes load floats into registers and sometimes read them directly from memory, and this can change the accuracy of the floats, resulting in a different conclusion. How can i avoid this?
Again, I want:
Can someone tell me what is the way to solve this problem?
, GCC , , . , . , GCC, , , (, , , , , -).
, , GCC, , . , , , , , , , . (?) , , , , , f-p, - . , , , , , , usd GCC.
, , ,
- () ? , ; , , . , . (, 5 , .)
, : , (, , , , , ), , , , 64- fp. . , , f-p, , ; , , .
, , - , , . f-p. , .
: , .
x86, , gcc, SSE2 ( ), .
PowerPC, , gcc not, fmadd ( , ), .
fmadd
--fast-math: , . Gcc , , , .
--fast-math
(exp, sin,...) , , .
exp
sin
, , ( C99 ), , C99 , . , , - . , , double, x86. : , .
double
Source: https://habr.com/ru/post/1734524/More articles:ColumnDefinition MinWidth does not work correctly - cssJava: The usual practice of creating a new thread when blocking? - javaHow to copy selected items from one list to another when a button is clicked in C # net? - c #How to access the main window when a child window exits a process in C # - c #How to elegantly split word pairs from a string in Perl? - perlHow to write a simple mail server in java? - javaHow does this compile? C # - c #Methods for creating a 2D game world - c ++Hide all select elements in a div using jquery? - jqueryDoes the connection at the level of functions in VC ++ have any negative effect? - c ++All Articles