How is -13 d = -13 in PHP?

后端 未结 4 906
南笙
南笙 2020-12-06 17:45

Derived from this question : (Java) How does java do modulus calculations with negative numbers?

Anywhere to force PHP to return positive 51?

update

4条回答
  •  粉色の甜心
    2020-12-06 17:50

    The PHP manual says that

    The result of the modulus operator % has the same sign as the dividend — that is, the result of $a % $b will have the same sign as $a. For example

    so this is not configurable. Use the options suggested in the question you linked to

提交回复
热议问题