Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.sys.acorn.programmer > #5922
| From | Martin <News03@avisoft.f9.co.uk> |
|---|---|
| Subject | Re: BASIC oddity? |
| Newsgroups | comp.sys.acorn.programmer |
| Date | 2020-01-03 19:31 +0000 |
| Message-ID | <582cb030b8News03@avisoft.f9.co.uk> (permalink) |
| References | <4adaa32c58.Alan.Adams@ArmX6.adamshome.org.uk> |
| Organization | None |
On 03 Jan in article <4adaa32c58.Alan.Adams@ArmX6.adamshome.org.uk>,
Alan Adams <alan@adamshome.org.uk> wrote:
> I've either discovered something odd but useful about BASIC, or
> I#ve got myself rather confused.
> The issue arose because I need to subtract one 5-byte time from
> another, returning the result in an integer.
> This will obviously fail if the result is too large to fit in an
> integer, but that is a large number of days, and will not occur in
> my particular case, as the computers will not need to run that
> long without a restart.
> What I thinki I've discovered is that although BASIC treats values
> that go beyone &7fffffff as negative numbers, when suntracting
> them one from another it treats them as unsigned. The following
> example demonstrates why I think this is the case.
> Note that I'm ignoring the MSB of the 5-byte times, as the test was
> created to fnd out what I needed to do with it, and seems to show
> that I simply ignore it.
> The weird example is the third, where subtracting a very large
> positive number from a very large negative number produces a
> positive result.
> Comments please:
I think you are confused. BASIC integers are *always* 4 bytes, never
5 bytes. The statement
I%=!buf1%
sets I% to the first 4 bytes at address buf1%
Which I think will explain your results.
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.
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.
--
Martin Avison
Note that unfortunately this email address will become invalid
without notice if (when) any spam is received.
Back to comp.sys.acorn.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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