Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

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

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...