hisoft basic- arithmetic overflow

Moderators: simonsunnyboy, Mug UK, Zorro 2, Moderator Team

User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2531
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

hisoft basic- arithmetic overflow

Postby charles » Sat Oct 12, 2019 11:39 pm

would anyone have a quik explaination why I recieve
arithmetic overflow in hisoft basic v2.10
by this one code

print 256*175

why it is envoked from within the editor
but
if I write it as a function or subroutine it
executes as intended?

def fnmul&(a&,b&)=a&*b&
print Fnmul&(256,175)


Charles

??is it because 16 bit bus? or hisoft only use referencing variables ?
The radioactive half-life : )
Atari is a lifestyle,not a hobby.
HOLD ON ! ! ! Im printing unreadable characters ...!

mlynn1974
Captain Atari
Captain Atari
Posts: 277
Joined: Mon Mar 03, 2008 10:33 pm
Contact:

Re: hisoft basic- arithmetic overflow

Postby mlynn1974 » Sun Oct 13, 2019 12:02 am

256*175=44800. This is well within the bounds of representing it as a floating point number.
Sinclair BASIC for example uses 1 exponent byte and 4 mantissa bytes.
I would think that as an inline function it expects a floating point number. It should work and not cause an overflow.

As a function it is coerced to an integer, passed on the stack as a 32-bit signed integer.
This would be done to make variable memory management easier.
Still got, still working: Atari 4Mb STe, 520STFM, 2.5Mb STF.
Hardware: Cumana CSA 354, Ultimate Ripper, Blitz Turbo, Synchro Express II (US and UK Versions).

User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2531
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

Re: hisoft basic- arithmetic overflow

Postby charles » Sun Oct 13, 2019 1:09 am

yes
seems ok until I go above integer ...

try this one
print (256*127)+256

it gets an "error during optimization"

funny , I prefer to sometime just use the basic editor as a calculator......for offsets ,data use ,array size ...

what I can easily assume is any true computation needs evaluated within a subroutine or function
and the editor body will just direct program flow......
which probally compliments what you depicted regarding variable memory management easier

however as inline function must need "pushed" to allow longs.floats.doubles.reals from command inline.
maybe compiler option to allow.....???? unknown a.t.m.
The radioactive half-life : )
Atari is a lifestyle,not a hobby.
HOLD ON ! ! ! Im printing unreadable characters ...!

User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2531
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

Re: hisoft basic- arithmetic overflow

Postby charles » Sun Oct 13, 2019 3:12 am

case solved
I was required to assign variable type placeholders

print 256&*256&

no errors !!!! : )
The radioactive half-life : )
Atari is a lifestyle,not a hobby.
HOLD ON ! ! ! Im printing unreadable characters ...!


Social Media

     

Return to “Other BASIC”

Who is online

Users browsing this forum: No registered users and 1 guest