有什么方法我可以找到更漂浮的变量包含分数? [英] Is there any way that i can find wether float variable contains fraction??

查看:45
本文介绍了有什么方法我可以找到更漂浮的变量包含分数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




有什么方法可以找到其他的浮动变量包含

分数??

例如: -


if(isWholeNumber(b))

{

//在这里做

}


isWholeNumber(float var)应为浮点数返回true,例如

10.000,11.000等


和对于像10.112这样的数字(如果它包含

分数),它应该是假的,11.092123

Hi

Is there any way that i can find wether float variable contains
fraction??
for eg:-

if( isWholeNumber(b))
{
//do here
}

isWholeNumber(float var) should return true for the float numbers like
10.000 ,11.000 etc

and it shuold be false for numbers like 10.112 (if it contains
fraction), 11.092123

推荐答案

nas写道:
nas wrote:




有什么办法可以找到其中的浮动变量包含

分数??

例如: -


if(isWholeNumber(b))

{

//在这里

}


isWholeNumber(float var)应该为浮动数字返回true,例如

10.000, 11.000等


对于像10.112这样的数字来说它是假的(如果它包含

fracti on),11.092123
Hi

Is there any way that i can find wether float variable contains
fraction??
for eg:-

if( isWholeNumber(b))
{
//do here
}

isWholeNumber(float var) should return true for the float numbers like
10.000 ,11.000 etc

and it shuold be false for numbers like 10.112 (if it contains
fraction), 11.092123



在你最喜欢的参考资料中查找fmod()。

look up fmod() in your favorite reference.


6月18日,8日:15 am,red floyd< no.s ... @ here.dudewrote:
On Jun 18, 8:15 am, red floyd <no.s...@here.dudewrote:

nas写道:
nas wrote:


有没有什么方法可以找到其他的浮点变量包含

分数?

例如: -
Is there any way that i can find wether float variable contains
fraction??
for eg:-


if(isWholeNumber(b))

{

//在这里做

}
if( isWholeNumber(b))
{
//do here
}


isWholeNumber(float var)应该为浮点数返回true,例如

10.000,11.000等
isWholeNumber(float var) should return true for the float numbers like
10.000 ,11.000 etc


,对于像10.112这样的数字,它应该是假的(如果它包含

分数),11.092123
and it shuold be false for numbers like 10.112 (if it contains
fraction), 11.092123


在你最喜欢的参考文献中查找fmod()。
look up fmod() in your favorite reference.



有趣。我会用modf()。 (两者都有效。)


-

James Kanze(来自CAI的GABI软件)电子邮件:ja ********* @ gmail.com

Conseils eninformatiqueorientéeobjet/

Beratung in objektorientierter Datenverarbeitung

9placeSémard,78210 St.-Cyr-l'' école,法国,+ 33(0)1 30 23 00 34

Interesting. I would have used modf(). (Both will work.)

--
James Kanze (GABI Software, from CAI) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l''école, France, +33 (0)1 30 23 00 34


2007-06-18 07:52,nas写道:
On 2007-06-18 07:52, nas wrote:




有什么方法可以找到其中的浮点变量包含

分数??

例如: -


if(isWholeNumber(b))

{

//在这里做

}


isWholeNumber(float var)应为浮点数返回true,如

10.000,11.000等


,对于像10.112这样的数字(如果它包含

分数),它是假的,11.092123
Hi

Is there any way that i can find wether float variable contains
fraction??
for eg:-

if( isWholeNumber(b))
{
//do here
}

isWholeNumber(float var) should return true for the float numbers like
10.000 ,11.000 etc

and it shuold be false for numbers like 10.112 (if it contains
fraction), 11.092123



Cast将数字转换为int并再次返回float / double并进行比较。


-

Erik Wikstr?m

Cast the number to int and back to float/double again and compare.

--
Erik Wikstr?m


这篇关于有什么方法我可以找到更漂浮的变量包含分数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆