Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : Simple Subtraction error?
Author | Message | ||||
Phil23 Guru Joined: 27/03/2016 Location: AustraliaPosts: 1664 |
Hi All, Can anyone tell me what's going wrong here? All I want to do is compare 2 numbers..... Seeing unexpected results at the console. [Code] print 5-7 -2 > print tmpout 13.6875 > print tmpinp 14.25 > print tmpout-tmpinp 0.5625 > print 13.6875-14.25 0.5625 >print 2.5-4.8 -2.3 > print 2.5555-4.85 -2.2945 > print 13.6875-14.25 0.5625 > print 13.687-14.25 0.563 > print 13.68-14.25 0.57 > print 13.6-14.25 0.65 > print 13-14.25 -1.25 [/code] Tried all those values & have no idea what's going on. Thanks Phil |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 5950 |
It is a good idea to give the version of MMBasic and the device (micromite or micromite+ etc) It looks like a bug but without the version, it is difficult to check. Jim VK7JH MMedit MMBasic Help |
||||
WhiteWizzard Guru Joined: 05/04/2013 Location: United KingdomPosts: 2794 |
Works ok on MMBasic v5.1 on 28pinner (version 5.1 from Geoff's site) For everything Micromite visit micromite.org Direct Email: whitewizzard@micromite.o |
||||
Phil23 Guru Joined: 27/03/2016 Location: AustraliaPosts: 1664 |
Thanks Jim, Realised that when I posted, particularly considering it's using the Beta. Took a while to get back to update my post. This is on the Beta, 5.2B2. 28 Pin Chip. I just added TmpOut-TmpInp to the test code I was working on, ran it, Ctrl-C when I saw the positive value then played at the basic prompt. The code is mainly test fragments. Phil 2016-06-13_230310_Spa_Controller_V1.zip |
||||
isochronic Guru Joined: 21/01/2012 Location: AustraliaPosts: 689 |
It looks like the subtraction is reverse order sometimes - maybe division is doing the same thing ? |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8648 |
Definitely a bug in 5.2. I've written to Geoff separately to alert him. Good catch Phil |
||||
Phil23 Guru Joined: 27/03/2016 Location: AustraliaPosts: 1664 |
Well, It's my first Beta Bug experience... But that's what Beta's are about, new features, and the simplest of existing functions that work, can unexpectedly take a turn, no guarantees. Just good that it's been accidently uncovered. Cheers. My Office PC's all run Win7 Pro, Beta Pack 1; Opps, That's Service Pack 1.......... |
||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3169 |
Yes, it is a bug. The bug was introduced in beta 2 and was actually in the routine that converted the number to ASCII characters for display. It only caused problems when the number to be displayed was negative and less than one (eg, -0.45). So your compare would be correct, it was just how the number was displayed. It will be fixed in the final release of V5.2. Thanks for finding and reporting it, very much appreciated. Geoff EDIT: Yes, very much, and a HUGE thanks to everyone who has used and/or found a bug in this and previous betas. Even if you just loaded the firmware and did not hit a bug that alone is valuable. Thanks EVERYONE very much, this software would not be half as good without your input. Geoff Graham - http://geoffg.net |
||||
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9133 |
Nice one, Phil!!! Only 315 posts old, and you have already found a rather subtle bug Well done. Another one squished. Smoke makes things work. When the smoke gets out, it stops! |
||||
Print this page |