Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 06:50 02 Aug 2025 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 : A bug report?

Author Message
Malibu
Senior Member

Joined: 07/07/2018
Location: Australia
Posts: 260
Posted: 04:46am 19 Mar 2019
Copy link to clipboard 
Print this post

G'day everyone
I've been playing around with a few new (new to me, anyway) functions in MM+ and maybe stumbled across a couple of bugs...
Here's the whittled down code to make it easier...

Option autorun on
OPTION EXPLICIT

dim Value=pi '<Gives value of 3.141592741, should be 3.141592653

cls
GuiSetup
page 1

sub GuiSetup
gui setup 1
font 4
gui displaybox #1,5,5,310,90,rgb(black),RGB(cyan)
gui displaybox #2,5,100,310,90,rgb(black),RGB(cyan)
ctrlval(1)=str$(Value),0,5 'A syntax error, but does not flag a fault
ctrlval(2)=str$(Value,0,5) 'Works correctly
end sub


Bug 1)
I selected PI as my number because it's a good number that I didn't need to type in... it's already there.
I remember PI to 7 decimal places from school days, so this value didn't look correct. I'm pretty sure it's not, but I'm happy to be proved wrong

Bug 2)
CtrlVal(1) line was a coding typo on my part, which MM happily ignored when it was running. CtrlVal(2) line is what I was trying to achieve with rounding to 5 decimal places.
Should CtrlVal(1) line have flagged a fault during run-time because the closing bracket is in the wrong position (which means what comes after is not valid code), or is it actually a valid bit of coding?

(Sorry, I meant to say it's MM Basic Ver 5.04.10)Edited by Malibu 2019-03-20
John
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 06:24am 19 Mar 2019
Copy link to clipboard 
Print this post

It looks like PI is stuck as single precision.
MMBasic V5.4.10 should be double precision and in V5.5.1 PI is defined as
#define PI_VALUE 3.14159265358979323

I don't know C anywhere well enough to say why it looses precision.

  Quote  myPi = 3.141592653589793238'462643532127
PRINT STR$(myPi,3,15)
PRINT STR$(PI,3,15)


> RUN
3.141592653589793
3.141592741012573
>


I don't know graphics programming well enough to comment on the other problem.

Jim
VK7JH
MMedit
 
Print this page


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

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025