Hi Dinoneno.
I have a quick question about using the RSX functions for REALs.
I am trying to do something like this:
When I run this in WinAPE as a BASIC program, it prints 33.614.
I want to do this in CPC Basic 3.
So far I have this:
(Note that I have the Real Numbers set to 5 in the IDE)
When this is compiled and run, it prints 200.
I expected it to print 34, which is 33.614 rounded up.
It looks as though line 110 is putting 1 into pow1 instead of 0.7.
I don't understand what I am doing wrong.
Can you help me?
Thanks.
[*** EDIT ***]
I think I have solved it!
This prints 34 as expected.
A little question - is it possible to set the number of real numbers in the program itself, instead of a the top of the IDE?
I have a quick question about using the RSX functions for REALs.
I am trying to do something like this:
- Code:
10 A=0.7^5*200
20 PRINT A
When I run this in WinAPE as a BASIC program, it prints 33.614.
I want to do this in CPC Basic 3.
So far I have this:
(Note that I have the Real Numbers set to 5 in the IDE)
- Code:
100 p0=0:p1=1:p2=2:m0=3:m1=4 ' indexes of real values
110 |CREAL,p1,0.7
120 |CREAL,p2,5
130 |POW,p0,p1,p2
140 |CREAL,m1,200
150 |MUL,m0,p0,m1
160 |CINT,@a,m0
170 PRINT a
When this is compiled and run, it prints 200.
I expected it to print 34, which is 33.614 rounded up.
It looks as though line 110 is putting 1 into pow1 instead of 0.7.
I don't understand what I am doing wrong.
Can you help me?
Thanks.
[*** EDIT ***]
I think I have solved it!
- Code:
10 p0=0:p1=1:m0=2:m1=3:d0=4:d1=5:d2=6 ' indexes of real values
20 |CREAL,d1,7
30 |CREAL,d2,10
40 |DIV,d0,d1,d2 ' d0 = 7/10 = 0.7
50 |CREAL,p1,5
60 |POW,p0,d0,p1
70 |CREAL,m1,200
80 |MUL,m0,p0,m1
90 |CINT,@a,m0
100 PRINT a
This prints 34 as expected.
A little question - is it possible to set the number of real numbers in the program itself, instead of a the top of the IDE?