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

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 1020 PRINT "1 / ",X," = ",1/X30 NEXT X40 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 7:39 am

### Re: BASIC returns zero instead of a decimal place number

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 12:28 pm

### Re: BASIC returns zero instead of a decimal place number

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 12:28 pm

### Re: BASIC returns zero instead of a decimal place number

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 12:28 pm

### Re: BASIC returns zero instead of a decimal place number

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 12:28 pm

### Re: BASIC returns zero instead of a decimal place number

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 7:39 am

### Re: BASIC returns zero instead of a decimal place number

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 12:28 pm

### Re: BASIC returns zero instead of a decimal place number

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 12:28 pm

### Re: BASIC returns zero instead of a decimal place number

brianvacha

Posts: 18
Joined: Mar Thu 05, 2009 12:28 pm

### Re: BASIC returns zero instead of a decimal place number

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 7:39 am

### Re: BASIC returns zero instead of a decimal place number

OK this must be the page you saw.

http://simonowen.com/sam/apple1emu/
Notice, about line 12 of the page:
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

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 12:28 pm

### Re: BASIC returns zero instead of a decimal place number

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 7:39 am

### Re: BASIC returns zero instead of a decimal place number

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 7:39 am

### Who is online

Users browsing this forum: No registered users and 1 guest