比较两个浮点值 [英] compare two float values
问题描述
任何人都可以告诉我如何比较两个浮点值
比如说
t和check两个变量声明浮点数如何比较t和
check
请尽快帮助我
ne ********** @ yahoo.co.in 写道:
可以有人告诉我如何比较两个浮点值
比如说
t和check两个变量声明浮点数如何比较t和
check
请尽快帮助我
浮动t,检查;
.. ..
if(t check)
printf("%f大于%f \ nt,检查);
else
printf(%f小于%f \ nt,检查);
不要比较平等,不会为漂浮(或双倍)工作,而是比较
差异agai NST适合您的准确性
一些delta b值$ B再见,乔乔
块引用>
约阿希姆·施密茨写道:
ne ********** @ yahoo.co.in 写道:
>任何人都可以告诉我如何比较两个浮点值
比如说
t和check是两个声明的变量漂浮如何比较t和
检查
请尽快帮助我
浮动t,检查;
...
if(t check)
printf("%f大于%f\ n) t,check);
else
printf("%f小于%f \ nt,检查);
不要比较平等,不适合浮动(或双倍),而是
比较适合您需要的某些delta的差异
准确度
oops,epsilon,而不是delta,在希腊字母中关闭一个......
实际上我想检查两个浮点值是否相等
等于
即假设t和t1是两个浮点数值我想检查一下是否
和t1是否相等
请以代码形式发送语法形式
请告诉我怎么做,
can anybody tell me how to compare two float values
say for example
t and check are two variables declared float how to compare t and
check
please help me as soon as possible解决方案ne**********@yahoo.co.in wrote:can anybody tell me how to compare two float values
say for example
t and check are two variables declared float how to compare t and
check
please help me as soon as possiblefloat t, check;
....
if ( t check)
printf("%f is greater than %f\n" t, check);
else
printf("%f is less than %f\n" t, check);
Don''t compare for equality, won''t work for float (or double), rather compare
the difference against some delta that suits your needs for accuracy
Bye, Jojo
Joachim Schmitz wrote:ne**********@yahoo.co.in wrote:>can anybody tell me how to compare two float values
say for example
t and check are two variables declared float how to compare t and
check
please help me as soon as possiblefloat t, check;
...
if ( t check)
printf("%f is greater than %f\n" t, check);
else
printf("%f is less than %f\n" t, check);
Don''t compare for equality, won''t work for float (or double), rather
compare the difference against some delta that suits your needs for
accuracyoops, epsilon, not delta, off by one in greek alphabeth...
actually i want to check wether two float values are equal or not
equal
i.e suppose t and t1 are two float values and i want to check wether t
and t1 are equal or not
please send in syntax form as in code form
please tell me how to do,
这篇关于比较两个浮点值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!