BBC BASIC
« floating point comparison »

Welcome Guest. Please Login or Register.
Mar 31st, 2018, 11:09pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Cross-platform BBC BASIC (Windows, Linux x86, Mac OS-X, Android, iOS, Raspberry Pi)
BBC BASIC Resources
BBC BASIC Help Documentation
BBC BASIC for Windows Home Page
BBC BASIC Programmers' Reference
BBC BASIC Beginners' Tutorial
BBC BASIC for SDL 2.0 Home Page
BBC BASIC Discussion Group

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: floating point comparison  (Read 152 times)
Ric
New Member
Image


member is offline

Avatar




PM


Posts: 30
xx floating point comparison
« Thread started on: Feb 8th, 2018, 9:02pm »

Evening all, can anyone tell me why this code doesn't work? On the face of it, it gives the right result, but if you change the values of [result] and [result+8] it simply fails!

Help, anyone
Code:
      MODE 7      DIM code% NOTEND AND 2047, code% 2047      DIM result 27      |result      = 11.87655      |(result+8)  = 17.87655      |(result+16) = 0.1      FOR opt% = 0 TO 2 STEP 2        P% = code%        [        OPT opt%        .start          mov                    eax,                       0        mov              DWORD [result+24],               0          fld              QWORD [result]        fld              QWORD [result+16]        faddp                  ST1,                       ST0        fcomp            QWORD [result+8]        fstsw                  ax        wait        sahf        ja                     next_calc        mov              DWORD [result+24],               2        ret          .next_calc          mov                    eax,                       0        fld              QWORD [result]        fld              QWORD [result+16]        fsubp                  ST1,                       ST0        fcomp            QWORD [result+8]        mov                    eax,                       0        fstsw                  ax        wait        sahf        jb                     end        mov              DWORD [result+24],               3        ret          .end        mov              DWORD [result+24],               1        ret        ]      NEXT      CALL start      PRINT !(result+24) 



Regards Ric
User IP Logged

You can't succeed without failing a few times first, CHIN UP.
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 803
xx Re: floating point comparison
« Reply #1 on: Feb 8th, 2018, 9:24pm »

on Feb 8th, 2018, 9:02pm, Ric wrote:
Evening all, can anyone tell me why this code doesn't work?

The code requires a *FLOAT 64 but as listed there isn't one. Of course it might simply have been lost in copying the listing into the forum, but it's the first thing I would check.

Richard.
User IP Logged

Ric
New Member
Image


member is offline

Avatar




PM


Posts: 30
xx Re: floating point comparison
« Reply #2 on: Feb 11th, 2018, 08:31am »

Thanks for the swift response Richard, you're right that the *FLOAT command is missing because of transposing into the forum. It turns out as you probably know there is nothing wrong with the code, it was the test on return from the routine that was at fault.

Regards Ric
User IP Logged

You can't succeed without failing a few times first, CHIN UP.
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls