如何测试double是否为整数 - How to test if a double is an integer

问题:

Is it possible to do this?是否有可能做到这一点?

double variable;
variable = 5;
/* the below should return true, since 5 is an int. 
if variable were to equal 5.7, then it would return false. */
if(variable == int) {
    //do stuff
}

I know the code probably doesn't go anything like that, but how does it go?我知道代码可能不会去这样的事情,但是如何走?


解决方案:

参考一: https://en.stackoom.com/question/fX3Q
参考二: https://stackoom.com/question/fX3Q
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章