We use cookies to provide you with a better experience. If you continue to use this site, we'll assume you're happy with this. Alternatively, click here to find out how to manage these cookies

hide cookie message
Contact Forum Editor

Send an email to our Forum Editor:


PLEASE NOTE: Your name is used only to let the Forum Editor know who sent the message. Both your name and email address will not be used for any other purpose.

Tech Helproom


It's free to register, to post a question or to start / join a discussion


 

basic calculation


amstrad
Resolved

Likes # 0

In basic, is there a check to see that the result of a calculation is a whole number and do something else if not?

Like this post
csqwared

Likes # 1

I think the 'MOD' function will do that for you e.g.

If MOD(number)=0

Then ..do something

Else ..do something else

End if

Where MOD checks to see if there is a remainder, in the instance above, no.

Long time since I did Basic.

Like this post
csqwared

Likes # 1

Just had a quick look on t'internet and the first line should probably be

If (n MOD 1)=0

where n is the number you are checking.

Try both.

Like this post
amstrad

Likes # 0

Thanks for the info. I'm not sure if the ZX 81 supports ( MOD ) we'll find out

Like this post
Terry Brown

Likes # 0

I did not know anyone was still using Clive's ZX81, what do you do on it.

If you need an emulator or more zx81 software, have a look at link.

Terry

enter link description here

1: http://uk.search.yahoo.com/search;ylt=A0geu8UEtahQ2n4A0pLBQx.?ei=UTF-8&fr=ush1-finance&p=zx81%20emulator&SpellState=&fr2=sp-qrw-corr-top/ "ZX81"

Like this post
Terry Brown

Likes # 0

http://uk.search.yahoo.com/search;ylt=A0geu8UEtahQ2n4A0pLBQx.?ei=UTF-8&fr=ush1-finance&p=zx81+emulator&SpellState=&fr2=sp-qrw-corr-top

Link did not work, try again

Terry

Like this post
Fermat's Theorem

Likes # 0

I know this has been ticked as resolved, but the handiest way of checking whether a number is, and ensuring that it is, a whole number in Basic is: if x<>int(x) then x=int(x). Depending on which Basic you're using, you may have to insert appropriate quotation marks or parenthesis around int(x). Hope this is of some use to you. :-)

Like this post
csqwared

Likes # 0

Fermat's Theorem

Not sure that's what amstrad had in mind. Does that not alter the value of the original number? e.g.

if 1.766<>int(1.766) then 1.766=int(1.766) i.e. 1

Reading the original post I understood just a check for integer was required, if not integer do something else.

Like this post
Fermat's Theorem

Likes # 0

Of course , you are correct. I thought he was tying to force the calculation to be an integer if it wasn't one already. The first half of the statement still holds true though - if x<>int(x) then ..... whatever he wants to do - goto,gosub, print, stop, end etc. I'm fascinated that he's still using a ZX 81 - I started with the Spectrum way back when!

Like this post
amstrad

Likes # 0

Thanks guys for the interest. I am building a magnet motor and using the ZX81 to do the calculations. It makes a brillient programable calculator which will print out the calculations and results and save all to tape. Unfortunately it died on me. Now looking for a bootable version of basic or OPL to put on my old laptop.

Like this post
csqwared

Likes # 0

amstrad

Have you tried here?-:

Basic

Thanks for the info about your project - those were the days. I even started to learn machine code on that machine!! Progressed to Commodore 64 then Amiga 500+ (along with AMOS basic).

Like this post

Reply to this topic

This thread has been locked.



IDG UK Sites

The best iPhone 6 alternatives: Price and specs compared with the best smartphones

IDG UK Sites

The top 10 Apple products ranked by pixel density: Which Apple devices have the sharpest screens?

IDG UK Sites

SBTRKT's Look Away webcam-based interactive music video won't keep your gaze

IDG UK Sites

Retina MacBook Air release date rumours and specs: Gold 12in Retina MacBook Air almost 1cm thinner...