Skip to main content

It depends on your compiler, and what exactly you mean by "the exact same operations".

For example, if the compiler is allowed to use fused multiply-add (FMA) then the result of ab + cda*b + c*d is not defined - it could be fma (a, b, cd) or fma (c, d, ab)fma (a, b, c*d) or fma (c, d, a*b), or ab + cd -a*b + c*d all three are equally valid and possibly different.

And one line in your source code can be compiled in different ways. Say this multiplication ab + cda*b + c*d is contained in a function that is inlined, then several calls from several places could produce different results. In C, C++, Objective-C that's perfectly legal.

And note that FMA is faster and has only one rounding error instead of two, so it is absolutely preferable. It can make a dramatic difference to the speed of floating-point heavy code. And note that since you start with two different variables, you cannot go through the same operations.

It depends on your compiler, and what exactly you mean by "the exact same operations".

For example, if the compiler is allowed to use fused multiply-add (FMA) then the result of ab + cd is not defined - it could be fma (a, b, cd) or fma (c, d, ab), or ab + cd - all three are equally valid and possibly different.

And one line in your source code can be compiled in different ways. Say this multiplication ab + cd is contained in a function that is inlined, then several calls from several places could produce different results. In C, C++, Objective-C that's perfectly legal.

And note that FMA is faster and has only one rounding error instead of two, so it is absolutely preferable. It can make a dramatic difference to the speed of floating-point heavy code. And note that since you start with two different variables, you cannot go through the same operations.

It depends on your compiler, and what exactly you mean by "the exact same operations".

For example, if the compiler is allowed to use fused multiply-add (FMA) then the result of a*b + c*d is not defined - it could be fma (a, b, c*d) or fma (c, d, a*b), or a*b + c*d all three are equally valid and possibly different.

And one line in your source code can be compiled in different ways. Say this multiplication a*b + c*d is contained in a function that is inlined, then several calls from several places could produce different results. In C, C++, Objective-C that's perfectly legal.

And note that FMA is faster and has only one rounding error instead of two, so it is absolutely preferable. It can make a dramatic difference to the speed of floating-point heavy code. And note that since you start with two different variables, you cannot go through the same operations.

added 105 characters in body
Source Link
gnasher729
  • 49.4k
  • 4
  • 71
  • 137

It depends on your compiler, and what exactly you mean by "the exact same operations".

For example, if the compiler is allowed to use fused multiply-add (FMA) then the result of ab + cd is not defined - it could be fma (a, b, cd) or fma (c, d, ab), or ab + cd - all three are equally valid and possibly different.

And one line in your source code can be compiled in different ways. Say this multiplication ab + cd is contained in a function that is inlined, then several calls from several places could produce different results. In C, C++, Objective-C that's perfectly legal.

And note that FMA is faster and has only one rounding error instead of two, so it is absolutely preferable. It can make a dramatic difference to the speed of floating-point heavy code. And note that since you start with two different variables, you cannot go through the same operations.

It depends on your compiler, and what exactly you mean by "the exact same operations".

For example, if the compiler is allowed to use fused multiply-add (FMA) then the result of ab + cd is not defined - it could be fma (a, b, cd) or fma (c, d, ab), or ab + cd - all three are equally valid and possibly different.

And one line in your source code can be compiled in different ways. Say this multiplication ab + cd is contained in a function that is inlined, then several calls from several places could produce different results. In C, C++, Objective-C that's perfectly legal.

And note that FMA is faster and has only one rounding error instead of two, so it is absolutely preferable. It can make a dramatic difference to the speed of floating-point heavy code.

It depends on your compiler, and what exactly you mean by "the exact same operations".

For example, if the compiler is allowed to use fused multiply-add (FMA) then the result of ab + cd is not defined - it could be fma (a, b, cd) or fma (c, d, ab), or ab + cd - all three are equally valid and possibly different.

And one line in your source code can be compiled in different ways. Say this multiplication ab + cd is contained in a function that is inlined, then several calls from several places could produce different results. In C, C++, Objective-C that's perfectly legal.

And note that FMA is faster and has only one rounding error instead of two, so it is absolutely preferable. It can make a dramatic difference to the speed of floating-point heavy code. And note that since you start with two different variables, you cannot go through the same operations.

Source Link
gnasher729
  • 49.4k
  • 4
  • 71
  • 137

It depends on your compiler, and what exactly you mean by "the exact same operations".

For example, if the compiler is allowed to use fused multiply-add (FMA) then the result of ab + cd is not defined - it could be fma (a, b, cd) or fma (c, d, ab), or ab + cd - all three are equally valid and possibly different.

And one line in your source code can be compiled in different ways. Say this multiplication ab + cd is contained in a function that is inlined, then several calls from several places could produce different results. In C, C++, Objective-C that's perfectly legal.

And note that FMA is faster and has only one rounding error instead of two, so it is absolutely preferable. It can make a dramatic difference to the speed of floating-point heavy code.