C++で初期化された変数に整数値または浮動小数点値があるかどうかを確認する方法はありますか?変数がC++の整数または浮動小数点かどうかチェック
サンプル・コード・ブロックを以下に示す:
int main()
{
double number = 9.99;
if (/*Checks whether the value of the 'number' is an integral*/)
cout << "The 'number' has an integral value";
else
cout << "It's not an integral value" // This condition will true if 'number' has a floating point number
return 0;
}
あなたは7.0を整数と見なしますか? – NathanOliver
std :: modfを使用するhttp://en.cppreference.com/w/cpp/numeric/math/modfこれは重複する可能性がありますhttp://stackoverflow.com/questions/1521607/check-double-variable-if-it整数と非浮動小数点を含む – DejaVuSansMono
整数値とは何ですか?整数値ですか? – mbaros