问题描述
我想了解在D语言运行时的一些code。好像有不同的职能为以下两件事情:
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.
推荐答案
我一无所知D语言,但我会高兴地回答您的标题问题:
I know nothing about the D language, but I'll happily answer the question in your title:
时的乘法总是不精确浮点运算可交换?
截至NaN值的有效载荷,是的。 IEEE-754浮点数乘法是可交换的(因此是添加)。如果你不知道什么是楠有效载荷,不用担心。
Up to the "payload" of NaN values, yes. IEEE-754 floating-point multiplication is commutative (and so is addition). If you don't know what the payload of a NaN is, don't worry about it.
这篇关于是乘法不精确的浮点运算总是交换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!