jbr*_*rre 5 python math go
我正在将一些旧的内容从 Python 翻译成 Go。在此代码中,我在 Python 中使用了向下取整除法和向下取整运算符。
d = b // c # (c isn't a comment, I use the // operator from python)
我的问题是,Go 中不存在这个运算符。在 Go 中翻译最简单的方法是什么?
zmb*_*mbq 7
如果b和c是整数,b / c则已经是楼层除法。如果它们是 float64,请使用math.Floor(b/c). 如果使用 float32 (或任何其他数字类型),则必须首先转换:math.Floor(float64(b)/float64(c))
b
c
b / c
math.Floor(b/c)
math.Floor(float64(b)/float64(c))
归档时间:
5 年,6 月 前
查看次数:
6540 次
最近记录: