Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.sys.acorn.programmer > #5924

Re: BASIC oddity?

Subject Re: BASIC oddity?
Newsgroups comp.sys.acorn.programmer
From Alan Adams <alan@adamshome.org.uk>
Date 2020-01-03 22:26 +0000
Message-ID <ef3ac02c58.Alan.Adams@ArmX6.adamshome.org.uk> (permalink)
References <4adaa32c58.Alan.Adams@ArmX6.adamshome.org.uk> <582cb030b8News03@avisoft.f9.co.uk> <quoa19$o6o$1@dont-email.me>
Organization Orpheus Internet Services

Show all headers | View raw


In message <quoa19$o6o$1@dont-email.me>
          druck <news@druck.org.uk> wrote:

> On 03/01/2020 19:31, Martin wrote:
>> There is no way for BASIC to subtract two 5-byte integers, apart from
>> spliiting each to one 5-byte integer and one 1-bute - and handling
>> the case where the result is negative.

> I'd always opt for a bit of assembler to do that, as its every easy to
> do arbitrary sized arithmetic when you've got access to the CPU flags.

>> However, if the difference is small, or you can ignore the lest
>> significant byte, you may be able to chose a single 4-bytes that will
>> provide the difference.

> I'd never recommend that, no matter how sort the interval, an over flow
> will occur at some point (the next in about 10 years from now).

> But anyway this highlights the lack of date and time manipulation SWIs
> in RISC OS. The only things you can do with a 5 byte time is convert it
> to or from a string.

> ---druck

I was starting to think of using assembler.

The difference between the times will never be more than a day. However 
the times are the time stored in the computer, which is close to the 
actual date and time. So it's not impossible that at some point each of 
the edge cases in the example might occur, i/e.

low word goes from 7f ff ff ff to 80 00 00 00
Low word goes from ff ff ff ff to 00 00 00 00 and the high byte is 
incremented.
(I'm going to ignore the case when time goes from ff ff ff ff ff to 00 00 
00 00 00.)

The example was written so that I could get my head round what happened 
when I subtracted 7f ff ff f0 from 80 00 00 0f for example. What I really 
didn't expect was a positive, and correct, answer, since PRINTing the 
variables said I was subtracting a large positive number from a large 
negative one. I expected a negative underflow, not a valid positive 
result.

(My suspicion is that the calculation is done ignoring the underflow, and 
the result returned is the remainder.)

If I could assume that this behaviour of BASIC would continue unchanged, 
then I could make use of it. Since it seems to me to be incorrect 
(although useful) I really ought to avoid using it, in case it gets 
corrected, and the only way I know to do that is assembler.

-- 
Alan Adams, from Northamptonshire
alan@adamshome.org.uk
http://www.nckc.org.uk/

Back to comp.sys.acorn.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

BASIC oddity? Alan Adams <alan@adamshome.org.uk> - 2020-01-03 17:16 +0000
  Re: BASIC oddity? Martin <News03@avisoft.f9.co.uk> - 2020-01-03 19:31 +0000
    Re: BASIC oddity? druck <news@druck.org.uk> - 2020-01-03 21:00 +0000
      Re: BASIC oddity? Alan Adams <alan@adamshome.org.uk> - 2020-01-03 22:26 +0000
        Re: BASIC oddity? Steve Drain <steve@kappa.me.uk> - 2020-01-04 10:40 +0000
          Re: BASIC oddity? Martin <News03@avisoft.f9.co.uk> - 2020-01-04 16:08 +0000
            Re: BASIC oddity? Alan Adams <alan@adamshome.org.uk> - 2020-01-04 16:22 +0000
              Re: BASIC oddity? David Higton <dave@davehigton.me.uk> - 2020-01-04 17:24 +0000
                Re: BASIC oddity? Alan Adams <alan@adamshome.org.uk> - 2020-01-04 18:47 +0000
                Re: BASIC oddity? Matthew Phillips <spam2011m@yahoo.co.uk> - 2020-01-06 08:58 +0000
                Re: BASIC oddity? David Higton <dave@davehigton.me.uk> - 2020-01-06 16:20 +0000
                Re: BASIC oddity? Matthew Phillips <spam2011m@yahoo.co.uk> - 2020-01-07 08:49 +0000
                Re: BASIC oddity? Martin <News03@avisoft.f9.co.uk> - 2020-01-07 11:20 +0000
                Re: BASIC oddity? David Higton <dave@davehigton.me.uk> - 2020-01-07 15:05 +0000
                Re: BASIC oddity? Matthew Phillips <spam2011m@yahoo.co.uk> - 2020-01-08 08:23 +0000
                Re: BASIC oddity? Alan Adams <alan@adamshome.org.uk> - 2020-01-08 10:26 +0000
                Re: BASIC oddity? druck <news@druck.org.uk> - 2020-01-08 21:02 +0000
                Re: BASIC oddity? Richard Ashbery <basura@invalid.addr.uk> - 2020-01-09 12:53 +0000
                Re: BASIC oddity? Steve Fryatt <news@stevefryatt.org.uk> - 2020-01-09 23:16 +0000
                Re: BASIC oddity? Steve Fryatt <news@stevefryatt.org.uk> - 2020-01-08 22:35 +0000
                Re: BASIC oddity? Martin <News03@avisoft.f9.co.uk> - 2020-01-08 23:51 +0000
          Re: BASIC oddity? Steve Drain <steve@kappa.me.uk> - 2020-01-10 11:30 +0000
            Re: BASIC oddity? Alan Adams <alan@adamshome.org.uk> - 2020-01-10 12:38 +0000
      Re: BASIC oddity? Jean-Michel <jmc.bruck@orange.fr> - 2020-01-06 20:39 +0100
        Re: BASIC oddity? Alan Adams <alan@adamshome.org.uk> - 2020-01-06 21:13 +0000
          Re: BASIC oddity? Steve Drain <steve@kappa.me.uk> - 2020-01-08 12:46 +0000

csiph-web