Bug 070528010: float compare in complex expression

List of known bugs
Locked
Author
Message
User avatar
srdjan
mikroElektronika team
Posts: 1552
Joined: 28 Dec 2005 12:47
Location: Serbia

Bug 070528010: float compare in complex expression

#1 Post by srdjan » 28 May 2007 09:23

Bug ID: #070528010
Submitted by: Rainer

Severity: Major, pic16/18 family, mikroPascal 6.02 and older
Status: Solved (will be implemented in next release.)

Description:
Routines for floating point comparing (<, >, >=, <=, ==, !=) used in complex expressions such as

Code: Select all

var
__value : real;
res : byte;
...
res := (__value < 1.00001) or (__value > 10.00001);
...
will not return expected values.

Note: In this case, complex expression are considered to be expression in which there is more than one function call (either system (implicitly called by compiler) or other explicit function calls made by user). All floating point operators are implemented as system functions. Only floating point compare operators are affected by this bug, all other operators will work. So, do not use them in complex expressions such as above.

Workaround:
Brake complex expressions in a number of simple expressions which do not have more than one function call as described above. Also, compare result variables, if there are any, should be declared as volatile. Here is an example:

Code: Select all

__value : real;
res : byte; volatile;
...
res := __value < 1.00001;
res := res or (__value > 10.00001);
...

Locked

Return to “mikroPascal Bug List”