📜  在 Julia 中获取除法后的余数 – mod() 方法

📅  最后修改于: 2021-11-25 04:46:09             🧑  作者: Mango

mod()是 julia 中的一个内置函数,用于在指定的被除数除以除数时返回余数。

示例 1:

# Julia program to illustrate 
# the use of mod() method
  
# Getting remainder when the specified
# dividend is divided by divisor.
println(mod(0, 3))
println(mod(1, 1))
println(mod(7, 2))

输出:

0
0
1

示例 2:

# Julia program to illustrate 
# the use of mod() method
  
# Getting remainder when the specified
# dividend is divided by divisor.
println(mod(5, 3))
println(mod(10, 2))
println(mod(7.3, 2))
println(mod(1.8, 0))
println(mod(-6, 4))
println(mod(-3, -2))

输出:

2
0
1.2999999999999998
NaN
2
-1