gpt4 book ai didi

clojure - Clojure 中 mod 和 rem 的区别

转载 作者:行者123 更新时间:2023-12-02 08:34:56 25 4
gpt4 key购买 nike

我无法理解这两个 (modrem) 函数之间的区别。

最佳答案

Clojuredoc 的 rem 示例描述差异:

;; rem and mod are commonly used to get the remainder.
;; mod means Gaussian mod, so the result is always
;; non-negative. Don't confuse it with ANSI C's %
;; operator, which despite being pronounced
;; 'mod' actually implements rem, i.e. -10 % 3 = -1.

user=> (mod -10 3)
2

user=> (rem -10 3)
-1

关于clojure - Clojure 中 mod 和 rem 的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37210994/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com