|
Forum Index : Microcontroller and PC projects : MMBasic V6.03.00 release candidates
| Author | Message | ||||
| Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3360 |
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 KingdomPosts: 4313 |
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 KingdomPosts: 97 |
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: HungaryPosts: 65 |
@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: AustriaPosts: 458 |
@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 KingdomPosts: 11279 |
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:58 by matherp |
||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 11279 |
V6.03.00RC2 PicoMiteRP2040V6.03.00RC1.zip PicoMiteRP2350V6.03.00RC1.zip Fixes to Beautify as described above |
||||
| terekgabor Regular Member Joined: 02/01/2026 Location: HungaryPosts: 65 |
Peter! File names hasn’t changed to RC2. G@bor |
||||
| fred777 Regular Member Joined: 01/07/2021 Location: United KingdomPosts: 77 |
Getting there but as DaveJacko says Lets try to overcome that irrational fear of empty lines. Empty lines are the quiet breaths of a program— the pauses where thought gathers before becoming logic. They are the whitespace between heartbeats, where structure reveals itself not by what is written, but by what is allowed to rest. In their silence, complexity untangles. In their absence, even brilliance feels crowded. An empty line is a small act of kindness from one mind to the next— a reminder that clarity is not only about words, but about the space that lets them be understood. |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2026 |