Inverting a number digits in Applesoft Basic

18 views Asked by At

I'm using the Apple II+ emulator in the following link: https://www.calormen.com/jsbasic/

To run the following code:

10 HOME
20 DEF FNMOD(NUMBER) = NUMBER - INT(NUMBER / 10) * 10
30 LET N = 135
40 LET REVERSE = 0 : LET RE = 0

100 GOTO 1000
200 PRINT REVERSE

500 END

1000 RE = FNMOD(N)  
1030 REVERSE = REVERSE * 10 + RE
1040 N = INT(N / 10)
1050 IF N = 0 THEN GOTO 200
1060 IF N > 0 THEN GOTO 1000

It should simply invert the number at line 30, so in this example print "531". However, I get it to print "11" and I don't understand why.

What am I missing?

Thank you.

1

There are 1 answers

0
Vinicius Lima Cordeiro On

I just noticed that just by changing the name of the variable "RE", the code exhibits the right behavior. But I don't get why.