如何測試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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章