Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 04:04 17 Jun 2024 Privacy Policy
Jump to

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: Australia
Posts: 1664
Posted: 11:58am 13 Jun 2016
Copy link to clipboard 
Print this post

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: Australia
Posts: 5950
Posted: 12:17pm 13 Jun 2016
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 2794
Posted: 01:00pm 13 Jun 2016
Copy link to clipboard 
Print this post

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: Australia
Posts: 1664
Posted: 01:03pm 13 Jun 2016
Copy link to clipboard 
Print this post

  TassyJim said   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


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 Edited by Phil23 2016-06-14
 
isochronic
Guru

Joined: 21/01/2012
Location: Australia
Posts: 689
Posted: 03:59pm 13 Jun 2016
Copy link to clipboard 
Print this post


It looks like the subtraction is reverse order sometimes - maybe
division is doing the same thing ?
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8648
Posted: 09:26pm 13 Jun 2016
Copy link to clipboard 
Print this post

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: Australia
Posts: 1664
Posted: 11:34pm 13 Jun 2016
Copy link to clipboard 
Print this post

  matherp said   Definitely a bug in 5.2. I've written to Geoff separately to alert him.
Good catch Phil


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: Australia
Posts: 3169
Posted: 10:45pm 14 Jun 2016
Copy link to clipboard 
Print this post

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:
  Phil23 said  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.

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.Edited by Geoffg 2016-06-16
Geoff Graham - http://geoffg.net
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9133
Posted: 04:51am 15 Jun 2016
Copy link to clipboard 
Print this post

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


To reply to this topic, you need to log in.

© JAQ Software 2024