|
Forum Index : Microcontroller and PC projects : MMBasic and string handling with non-integers
| Author | Message | ||||
| vegipete Guru Joined: 29/01/2013 Location: CanadaPosts: 1149 |
Is this the expected behaviour? > a$ = "123456789" > print left$(a$,1.4) 1 > print left$(a$,1.5) 12 What is happening, you ask? The number part of the left$ function is being ROUNDED, not truncated. This is with a CMM2, although I presume other MMBasic devices do the same. Comments? Visit Vegipete's *Mite Library for cool programs. |
||||
TassyJim![]() Guru Joined: 07/08/2011 Location: AustraliaPosts: 6360 |
That is what happens when you get a float to integer conversion. If you prefer to truncate, use INT or FIX dim integer x dim float y for y = 0 to 2 step 0.1 x = y print x,y next y Jim VK7JH MMedit |
||||
| vegipete Guru Joined: 29/01/2013 Location: CanadaPosts: 1149 |
Okey-dokey. FIX it is. Visit Vegipete's *Mite Library for cool programs. |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |