BASIC returns zero instead of a decimal place number

Get help here getting your replica 1 going

BASIC returns zero instead of a decimal place number

Postby George » Oct Sat 02, 2010 5:42 am

Hi, whenever I'm doing division of any sort in basic, and the number has a decimal place, for example 0.52 or 3.78, BASIC returns a zero, and nothing else. For example, from looking at this code you'd expect BASIC to give me 10 numbers with decimal places or similar, but it returns zero for each one:

Code: Select all
10 FOR X = 1 to 10
20 PRINT "1 / ",X," = ",1/X
30 NEXT X
40 END


Have I messed up or corrupted basic somehow? I worry too much about this simple stuff but I was just learning BASIC (yes, learning it) and I'd like it to work correctly, or have I just made a huge programming mistake?
George
 
Posts: 27
Joined: Jul Sat 10, 2010 8:39 am

Re: BASIC returns zero instead of a decimal place number

Postby brianvacha » Oct Sat 02, 2010 1:01 pm

I am not sure I do not have mine yet but this should be an integer basic and will only show whole numbers not any decimal points. To fake it you multiply your original number by 10 or 100 if you want 1 or 2 decimal places, do the math, then you have to divide by what you had multiplied by and subtract it from the math result to get the decimal digits. Clear as mud I suppose.

I hope this is some help.
Brian
brianvacha
 
Posts: 18
Joined: Mar Thu 05, 2009 1:28 pm

Re: BASIC returns zero instead of a decimal place number

Postby brianvacha » Oct Sat 02, 2010 2:34 pm

:oops: I went in the wrong direction.
As a continuation of above you can use a fake scientific notation.


I might be missing some commas in there

10 FOR X = 1 to 10
20 PRINT "1 / ",X," = ",100/X,"X10-2E"
30 NEXT X
40 END

http://en.wikipedia.org/wiki/Floating_point
brianvacha
 
Posts: 18
Joined: Mar Thu 05, 2009 1:28 pm

Re: BASIC returns zero instead of a decimal place number

Postby brianvacha » Oct Sat 02, 2010 4:33 pm

Aha here it is.
"Integer BASIC, written by Steve Wozniak, was the BASIC interpreter of the Apple I and original Apple II computers. The most frequently cited flaw of Integer BASIC was, as one might expect from the name, that its variables were all 16-bit integers and it was very difficult to write a program that could do calculations using floating point numbers, or even integers outside of the range -32768 to +32767. It was therefore very difficult to write financial or math programs."

http://en.wikipedia.org/wiki/Integer_BASIC
brianvacha
 
Posts: 18
Joined: Mar Thu 05, 2009 1:28 pm

Re: BASIC returns zero instead of a decimal place number

Postby brianvacha » Oct Sat 02, 2010 4:54 pm

Here is a great article about getting "Microsoft Basic" to work on the Apple II as "Applesoft Basic".

http://apple2history.org/history/ah16/
brianvacha
 
Posts: 18
Joined: Mar Thu 05, 2009 1:28 pm

Re: BASIC returns zero instead of a decimal place number

Postby George » Oct Sat 02, 2010 5:43 pm

Thanks for the information!
It was probably a dream or something but I'm sure I once had it display decimal point numbers, but seems like it doesn't, thanks again!
George
 
Posts: 27
Joined: Jul Sat 10, 2010 8:39 am

Re: BASIC returns zero instead of a decimal place number

Postby brianvacha » Oct Sat 02, 2010 6:03 pm

Be grateful for modern computers and software, floating point the hard way in software.

http://pages.cs.wisc.edu/~smoler/x86tex ... .flpt.html
brianvacha
 
Posts: 18
Joined: Mar Thu 05, 2009 1:28 pm

Re: BASIC returns zero instead of a decimal place number

Postby brianvacha » Oct Sat 02, 2010 7:36 pm

Sorry about all the posts but this peaked my interest, thanks George for the motivation. Here is a good link to doing math in micro controllers.

http://en.wikipedia.org/wiki/Fixed-point_arithmetic

Brian
brianvacha
 
Posts: 18
Joined: Mar Thu 05, 2009 1:28 pm

Re: BASIC returns zero instead of a decimal place number

Postby brianvacha » Oct Sat 02, 2010 7:41 pm

brianvacha
 
Posts: 18
Joined: Mar Thu 05, 2009 1:28 pm

Re: BASIC returns zero instead of a decimal place number

Postby George » Oct Sun 03, 2010 5:03 am

I also remember seeing an image somewhere of someones replica 1 executing the exact same code sample I provided, only they got the correct answers and not zero?
George
 
Posts: 27
Joined: Jul Sat 10, 2010 8:39 am

Re: BASIC returns zero instead of a decimal place number

Postby brianvacha » Oct Mon 04, 2010 6:21 pm

OK this must be the page you saw.

http://simonowen.com/sam/apple1emu/
Notice, about line 12 of the page:
Software

For your convenience, the emulator is pre-loaded with the following software:

* Tom Greene's port of Applesoft BASIC at address 6000
Enter 6000R at the monitor prompt to launch Applesoft BASIC, etc.

Below in the picture notice the ] prompt and that the program starts at address 6000

Goto http://school.anhb.uwa.edu.au/personalp ... usader.htm
and download The KRUSADER Toolkit . It is easy to use, go to the emulator tab enter E000R to get to basic and you will get a >@ prompt, just type "PRINT 9/2" AND PRESS ENTER no line number after that enter your program and see what happens.
brianvacha
 
Posts: 18
Joined: Mar Thu 05, 2009 1:28 pm

Re: BASIC returns zero instead of a decimal place number

Postby George » Oct Fri 15, 2010 5:12 pm

I'm using OSX, I can't use this emulator :(

ironic as this was designed for an apple computer (albeit a very old one :p)
George
 
Posts: 27
Joined: Jul Sat 10, 2010 8:39 am

Re: BASIC returns zero instead of a decimal place number

Postby George » Oct Fri 15, 2010 5:22 pm

I do have a serial connector, I can port the new version onto my replica, right?
What if I want to replace the ROM with the standard version that came with the kit if I'm not happy?
George
 
Posts: 27
Joined: Jul Sat 10, 2010 8:39 am


Return to Troubleshooting

Who is online

Users browsing this forum: No registered users and 2 guests

cron