davidb 0 Posted February 27, 2012 Report Share Posted February 27, 2012 Hi, Problem: The following simply test code demonstrates the problem using signed data types and the comparison if (error > limit). Expected Behaviour: To work correctly x should be 1 less than y at the end of the comparison loop. If the code is compiled for a 16F887 then all works as expected with error defined as any data type; signed char, signed short or signed long. If the code is compiled for a 18F4520 then it fails if error is a signed short but works correctly for signed char and signed long. It also works correctly if the limit definition is changed to any signed data type. #include <system.h> static signed short error = -60; static unsigned char x; static unsigned char y; #define limit -50 //signed short limit = -50; void main() { for (error = -60; error < 60; error++) { if (error > limit) //Fails { x++; } if (error >= limit) //O.K. { y++; } } for (;; } IDE: MPLAB V8.83 Compiler: SourceBoost C V7.05.1 Targets: PIC16F887, PIC18F4520 Reproducible: 100% OS: XP Pro, Vista Regards davidb Quote Link to post Share on other sites
Dave 0 Posted February 28, 2012 Report Share Posted February 28, 2012 davidb, Hi, Problem: The following simply test code demonstrates the problem using signed data types and the comparison if (error > limit). Expected Behaviour: To work correctly x should be 1 less than y at the end of the comparison loop. This is definitely a problem.Thanks for reporting it. Regards Dave Quote Link to post Share on other sites
Hiker 0 Posted March 30, 2012 Report Share Posted March 30, 2012 I have also had problems with comparisons between Interger and constants. My results show a pattern that only a few combinations of small negative constants (8 bit) there are problems with. if(SignInt >= -20) if(SignInt > -21) // Error // if(SignInt <= -20) // Error // if(SignInt < -19) if(SignInt <= 20) if(SignInt < 21) if(SignInt >= 20) if(SignInt > 19) if(SignInt >= -300) if(SignInt > -301) if(SignInt <= -300) if(SignInt < -299) if(SignInt <= 300) if(SignInt < 301) if(SignInt >= 300) if(SignInt > 299) When can we expect the error to be corrected? BoostC Compiler Version 7.03 for PIC18, MPLAB v8.63, Win7 Pro 64 Quote Link to post Share on other sites
davidb 0 Posted July 5, 2012 Author Report Share Posted July 5, 2012 Dave, Was this problem supposed to have been fixed in V7.1? Regards davidb Quote Link to post Share on other sites
Pavel 0 Posted July 6, 2012 Report Share Posted July 6, 2012 Was this problem supposed to have been fixed in V7.1? No this problem is not fixed yet Regards, Pavel Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.