CPC Basic

Would you like to react to this message? Create an account in a few clicks or log in to continue.
CPC Basic

Basic cross-compiler for Amstad CPC


    problem with |MUL ?

    avatar
    poppichicken


    Posts : 16
    Join date : 2012-03-16

    problem with |MUL ? Empty problem with |MUL ?

    Post  poppichicken Tue Apr 24, 2012 5:09 pm

    Hi there.

    I've been trying to convert an old program to CPC Basic 3, and I've come across what may be an error.


    Code:
    10 piHalf=0
    20 con2=0:|VAL,con2,"1.0"
    30 |PI,piHalf
    40 |MUL,piHalf,piHalf,con2
    50 |CINT,@tmp,piHalf
    60 PRINT tmp
    In the attached code, I'm expecting to see 3 printed on-screen, as PI*1=PI.
    Instead, I am getting 10 being printed.
    (I have Real Numbers set to 2 in the IDE).


    When I change line 20 to:
    Code:
    20 con2=0:|VAL,con2,"2.0"
    I am expecting it to print 6 to the screen, but it is still printing 10.


    Am I doing something wrong, or is |MUL flawed?


    When I change line 40 to:
    Code:
    40 |ADD,piHalf,piHalf,piHalf
    I get 6 being printed, which is what I expect, as I am simply adding PI to itself


    *****
    EDIT
    *****

    Please ignore this question.
    I was indeed making a mistake - I wasn't setting the indexes for the REALs correctly.

    Changing line 20 to:
    Code:
    20 con2=1:|VAL,con2,"1.0"
    has fixed the problem.

    Embarassed

      Similar topics

      -

      Current date/time is Tue Mar 19, 2024 2:11 pm