Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 18:39 06 May 2026 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 : MMBasic V6.03.00 release candidates

     Page 2 of 2    
Author Message
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3360
Posted: 08:25pm 05 May 2026
Copy link to clipboard 
Print this post

This is a typical example of floating point error.  Calculation errors in floating-point math are not "bugs" in the language but a fundamental limitation of storing infinite decimals in finite space.

The issue here is that 0.1 cannot be represented exactly in binary. Every time you press a key, a tiny rounding error is added to a. Eventually, you’ll see values like 0.3000000000000001 or 0.6999999999999999.In BASIC dialects (like MMBasic), the most reliable fix is to calculate with integers and scale the output for the display.
Geoff Graham - http://geoffg.net
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4313
Posted: 09:18pm 05 May 2026
Copy link to clipboard 
Print this post

Some examples of programming around it often use a small value - search on epsilon (or floating point epsilon) as that's what it tends to be called.

John
 
DaveJacko
Regular Member

Joined: 25/07/2019
Location: United Kingdom
Posts: 97
Posted: 09:42pm 05 May 2026
Copy link to clipboard 
Print this post

Thanks for beautify, Peter,
great help for hobbyists with older brains and eyes
along with fred777 and toml,


I do think that leaving blank lines intact for readability would be better

(more blank lines, for emphasis)


thanks, Dave
Try swapping 2 and 3 over
 
terekgabor
Regular Member

Joined: 02/01/2026
Location: Hungary
Posts: 64
Posted: 05:37am 06 May 2026
Copy link to clipboard 
Print this post

@matherp

Peter!

Just a small idea. Can be good if we can use string variable (not only unquoted constant string) for object names in STAR and ASTRO commands.

Better way to build up a kind of epheneris program for example.

G@bor
 
ville56
Guru

Joined: 08/06/2022
Location: Austria
Posts: 458
Posted: 06:50am 06 May 2026
Copy link to clipboard 
Print this post

@Peter,

Beautify spoils labels ... in the attached code, after edit/^A/F2 there are spaces in front of the label b_loop: inserted and the code does fail with

[11] If in_str <> "" Then GoTo b_loop
Error : Cannot find label

Interestingly, there are seemingly 2 character positions inserted but if there is only one char to remove. The code runs again if the inserted chars (or char?) are removed.

Version is:
PicoMite MMBasic RP2350B V6.03.00RC1

failing code is:

 '
 OPTION EXPLICIT
 OPTION DEFAULT NONE
 
 Option tracecache on 128
 
 b_test("test")
 
end
 ' ------------ END main ----------------------------------

sub b_test(in_str as string)

b_loop:
 print "in b_loop"
 pause 300
 if in_str <> "" then goto b_loop

end sub

                                                                 
73 de OE1HGA, Gerald
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 11278
Posted: 07:22am 06 May 2026
Copy link to clipboard 
Print this post

Will fix in next RC. I also want to fix the behaviour of program with line numbers. Please can someone post a fully line numbered example for me to test with. Intended behaviour will be:

The F12 Beautify command aligns code using 2-space block indentation. It detects whether a program is line-numbered by examining the first non-comment line:

If that line begins with a line number, the whole program is treated as numbered. All statements are aligned past the widest line number found, and block indentation is added on top of that base column.
Otherwise, the program is treated as unnumbered. Any stray numbered lines used purely as GoTo/GoSub targets will be pushed flush to the left margin and will not align with the surrounding block, since they are handled like labels.

Recommendation: in modern, mostly-unnumbered programs prefer named labels (e.g. retry:) over numeric line numbers as branch targets. Labels are also forced flush left by Beautify, but they read more clearly, are not confused with numbered-program formatting, and keep the rest of the block visually consistent.

The F12 Beautify command forces any line that begins with a label to column 0 — including anything written after the label on the same line — so a construct such as:
retry: Print "x"
will lose the indent of its surrounding block. Writing the label on a line by itself keeps both the label visible at the margin and the following code correctly indented within its Sub, For or If block.

When F12 Beautify is pressed and the program already contains blank lines other than those separating subroutines/functions, the editor asks KEEP BLANK LINES? (Y/N). Choose Y to preserve your blank lines (consecutive blanks are collapsed to one); choose N to strip them all. Either way, a single blank line is always ensured after every End Sub / End Function. Press Esc at the prompt to cancel.
Edited 2026-05-06 18:39 by matherp
 
     Page 2 of 2    
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 2026