在Python中,我要做的是这样的(其中n
为浮点/双精度(:
def check_int(n):
if not isinstance(n, numbers.Integral):
raise TypeError()
既然C/C++是强类型的,那么什么样的投射和比较魔术最适合这个目的呢?
我最好想知道它是如何在C.中完成的
使用floor
#include <cmath>
if (floor(n) == n)
// n is an integer (mathematically speaking)