在我测试过的语言中,- (x div y )
不等于-x div y
;我用Python测试了//
次,用Ruby测试了/
次,用Perl 6测试了div
次;C has a similar behavior
这种行为通常符合规范,因为div
通常被定义为the rounding down of the result of the division,但是从算术的Angular 来看,它没有太多意义,因为它使div
根据符号以不同的方式表现,并且它会导致像this post on how it is done in Python这样的混淆.
这个设计决策背后是否有一些具体的理由,或者仅仅是从头定义的?在一篇解释Python是如何实现的博客文章中,显然是Guido van Rossum uses a coherency argument,但如果你 Select 汇总,你也可以有一致性.