|
Re: if comparison perform differently between Lite-c, C-Script.
[Re: Jethro]
#270860
06/10/09 10:37
06/10/09 10:37
|
Joined: Aug 2000
Posts: 1,140 Baunatal, Germany
Tobias
Moderator
|
Moderator
Joined: Aug 2000
Posts: 1,140
Baunatal, Germany
|
I think this is related to comparing float numbers with "==".
In programming course I learnt that due to limited computer precision, float numbers can not be compared with == or !=, but always with <, <=, >, >=.
This_Var=0.1; if (This_Var > 0.0999) printf("Match!"); if (This_Var < 0.1001) printf("Match!");
|
|
|
Re: if comparison perform differently between Lite-c, C-Script.
[Re: Tobias]
#270864
06/10/09 10:44
06/10/09 10:44
|
Joined: May 2002
Posts: 7,441
ventilator
Senior Expert
|
Senior Expert
Joined: May 2002
Posts: 7,441
|
so why doesn't the above work in Lite-c. because in lite-c the literals are doubles not vars like in c-script.
|
|
|
Re: if comparison perform differently between Lite-c, C-Script.
[Re: Tobias]
#270915
06/10/09 14:05
06/10/09 14:05
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
I think ventilator is right. A regular workaround I use is if(This_Var==(var)0.1) beep();
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
|