Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
776 views
in Technique[技术] by (71.8m points)

arrays - Is multiplication always commutative in inexact floating point arithmetic?

I'm trying to understand some code in the D language runtime. It seems like there are separate functions for the following two things:

array1[] += scalar * array2[];
array1[] += array2[] * scalar;

Why can't these be done with one function? I thought multiplication was commutative even in inexact floating-point arithmetic.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I guess the difference is just in the function prototypes - one is (double, double[]) and the other is (double[], double). But the result should be the same either way.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...