相关疑难解决方法(0)

如何确定十进制/双精度是否为整数?

如何判断小数或双精度值是否为整数?

例如:

decimal d = 5.0; // Would be true
decimal f = 5.5; // Would be false
Run Code Online (Sandbox Code Playgroud)

要么

double d = 5.0; // Would be true
double f = 5.5; // Would be false
Run Code Online (Sandbox Code Playgroud)

我想知道这个的原因是我可以通过编程方式确定是否要使用.ToString("N0")或输出值.ToString("N2").如果没有小数点值,那么我不想显示.

c#

210
推荐指数
7
解决办法
18万
查看次数

有没有办法检查变量是否是整数?C++

我需要检查变量是否是整数,比如我有代码:

double foobar = 3;
//Pseudocode
if (foobar == whole)
    cout << "It's whole";
else
    cout << "Not whole";
Run Code Online (Sandbox Code Playgroud)

我该怎么做?

c++ variables floating-point function

7
推荐指数
2
解决办法
4万
查看次数

标签 统计

c# ×1

c++ ×1

floating-point ×1

function ×1

variables ×1