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


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

Re: BASIC oddity?

Subject Re: BASIC oddity?
Newsgroups comp.sys.acorn.programmer
From Alan Adams <alan@adamshome.org.uk>
Date 2020-01-04 18:47 +0000
Message-ID <930f302d58.Alan.Adams@ArmX6.adamshome.org.uk> (permalink)
References (3 earlier) <ef3ac02c58.Alan.Adams@ArmX6.adamshome.org.uk> <qupq4i$4nf$1@gioia.aioe.org> <582d216fd8News03@avisoft.f9.co.uk> <a2bf222d58.Alan.Adams@ArmX6.adamshome.org.uk> <d46b282d58.DaveMeUK@BeagleBoard-xM>
Organization Orpheus Internet Services

Show all headers | View raw


In message <d46b282d58.DaveMeUK@BeagleBoard-xM>
          David Higton <dave@davehigton.me.uk> wrote:

> In message <a2bf222d58.Alan.Adams@ArmX6.adamshome.org.uk>
>           Alan Adams <alan@adamshome.org.uk> wrote:

>>The thing I found surprising is that BASIC displays the values in I% and
>>J% using a signed interpretation, but does the subtraction in an unsigned
>>fashion. It's this inconsistency that worries me, in case at some future
>>date is is "corrected".

> It's not inconsistent.  This is just how 2's complement addition and
> subtraction work.  Perhaps you need to work through some more examples.
> Doing them on paper, perhaps with a more limited number of bits to make
> it less laborious, might help convince you.

Ity may not be inconsistent if you view it from the viewpoint of 
assembler, but it is very much inconsistent from the viewpoint of BASIC

-(very large number) - (another very large number) should never result in 
a positive answer.

BASIC shows these values as negative, and returns positive.

That's inconsistent "within the BASIC language scope". It should, to be 
consistent, return an underflow error.

Where it is consistent is that it does the same thing with addition, but 
not with multiplication.

>a%=&7ffffff0
>b%=&7fffff00
>PRINT a%
2.14748363E9
>PRINT b%
2.14748339E9
>PRINT a%+b%
      -272
>PRINT a%*2
4.29496726E9
>PRINT b%*2
4.29496678E9
>
>PRINT ~(a%*2)
Number too big


-- 
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