Loop for-next taking only integer values (v1.0.1b2.44)

new BookmarkLockedFalling
adolfomartinfuentes
New Member
*

adolfomartinfuentes Avatar

Posts: 2

Post by adolfomartinfuentes on Oct 7, 2023 6:20:43 GMT -5

Hello everyone,

as part of a larger program I am experiencing problems with a simple for-next loop,

-- sample code begins --

010 FOR X = 0 TO 1 STEP 0.1
020 PRINT X
030 NEXT X
040 END

-- sample code ends --

as the variable X is taking only the limiting integer values 0 and 1, instead of the values 0, 0.1, 0.2, ..., 0.9, 1, as one would expect.

The issue is experienced in the free version of RunBASIC v1.0.1b2.44 for Mac OS X, as well as in the current online version.

Could anybody be of help?

Thank you very much!

Sincerely,

Adolfo

StefanPendl
Global Moderator
*****

StefanPendl Avatar

Run for BASIC ...
Posts: 945

[b]Stefan[/b] - [a href=http://stefanpendl.runbasichosting.com/]Homepage[/a][br][br][b]Please give credit if you use code I post, no need to ask for permission.[/b][br][br]Run BASIC 1.01, Fire-/Waterfox (IE11, Edge), Windows 10 Professional x64, Intel Core i7-4710MQ 2.5GHz, 16GB RAM
adolfomartinfuentes
New Member
*

adolfomartinfuentes Avatar

Posts: 2

Post by adolfomartinfuentes on Oct 10, 2023 3:09:17 GMT -5

Hello Stefan,

thank you very much for your answer.

The reason for my post is that I have been working on the contents of a BASIC course during the last days and I did not want to give the students such an example.

I have been reading the ANSI BASIC standards during the last days and in the standard for Minimal BASIC it is stated that the normal behaviour should be to set the STEP to 1 when no value is given, but constructions such as FOR X = 0 TO 1 STEP 0.1 should work within the limits of machine arithmetic.

Wish you a nice day!

Sincerely,

Adolfo