## Back to Basic

Moderator: Mike Everman

PyroJoe
Posts: 1743
Joined: Wed Aug 29, 2007 5:44 pm
Antipspambot question: 125
Location: Texas

### Re: Back to Basic

From the help file:
"In Just BASIC, numeric variables hold either a double-precision floating point value, or an integer. A floating point value will be converted to an integer if its fractional part is zero when it is assigned to a variable. Integers in Just BASIC can be huge."

"Only nine digits are displayed when floating point values are printed, unless the USING() function is used to force the display of the number of digits desired after the decimal point."

WebPilot
Posts: 3716
Joined: Tue Dec 07, 2004 6:51 pm
Antipspambot question: 0
Location: 41d 1' N 80d 22' W

### Re: Back to Basic

Hey Joe, (sounds like a song, doesn't it?)

By default, it works in double precision? OK, I remember it was pretty accurate 'right out of the box.' I use to do a lot of programming in BASIC; it was accurate enough to do fractals.

I found the time to look at your code, and yes, I was going to suggest that every time you assign a variable a value, that you use decimal notation not an integer. Always use floats unless you really mean an integer, like exponentials in powers.

for example:

9 pi = asn(1.0) * 2.0

14 l=0.0

25 I=w*h^3 /12.0

As you read, if the interpreter is called upon to do integer division, it throws away the remainder. If it then assigns this division to a float value, the result could contain HUGE errors.

~ but that's not your problem

The deviation is caused by your value for ' input4 .457

Here is a log of a run I did of your code in the interpreter I can use. I performed only one modification, the asn(1.0) replacement.

Your code results now match the results in my original post:

Congrats!

PyroJoe
Posts: 1743
Joined: Wed Aug 29, 2007 5:44 pm
Antipspambot question: 125
Location: Texas

### Re: Back to Basic

Thanks, thought that input4 looked suspicious,
Attachments
code3.zip

WebPilot
Posts: 3716
Joined: Tue Dec 07, 2004 6:51 pm
Antipspambot question: 0
Location: 41d 1' N 80d 22' W

### Re: Back to Basic

From the help file:
"In Just BASIC, numeric variables hold either a double-precision floating point value, or an integer. A floating point value will be converted to an integer if its fractional part is zero when it is assigned to a variable. Integers in Just BASIC can be huge."
I've been doing some testing with my BASIC interpreter and here are some behaviors that I discovered.
1. assigning a variable the value of one integer divided by another with no remainder gives an integer:

bwBASIC: c = 4/2
bwBASIC: print c
2
2. assigning a variable the value of one float divided by another with no remainder gives an integer (as predicted in the above quote):

bwBASIC: c=4./2.
bwBASIC: print c
2
3. Dividing 2 integers gives a float:

bwBASIC: print 2/3
0.6666667
4. Dividing 2 floats also gives a float:

bwBASIC: print 2./3.
0.6666667
5. assigning a variable the value of one integer divided by another gives a float:

bwBASIC: a=2/3
bwBASIC: print a
0.6666667
6. assigning a variable the value of one integer divided by another and using the INT command gives an integer:

bwBASIC: a=int(4/3)
bwBASIC: print a
1
7. finding the remainder when dividing two integers using the MOD command:

bwBASIC: b=5 mod 3
bwBASIC: print b
2
8. the INT of the division of two floats gives an integer:

bwBASIC: a = int(4./3.)
bwBASIC: print a
1
9. finding the remainder of the division of one float by another using the MOD command gives an integer:

bwBASIC: b = 5. mod 3.
bwBASIC: print b
2
CONCLUSION:

It seems ok to mix floats with integers in BASIC; I don't do it.

I still advise the reader to use floats whenever one means floats and integers for loop variables and most exponentiation. It is a good habit to get into doing. Other programming languages make the distinction between the two and you will be "one step ahead of the rest" when you get there.

WebPilot
Posts: 3716
Joined: Tue Dec 07, 2004 6:51 pm
Antipspambot question: 0
Location: 41d 1' N 80d 22' W

### Re: Back to Basic

It was not my intention to 'scare' anyone with my previous post. I was just being rigorous.

PyroJoe
Posts: 1743
Joined: Wed Aug 29, 2007 5:44 pm
Antipspambot question: 125
Location: Texas

### Re: Back to Basic

BASIC is probably a blessing for those running loose. No telling how many retired "sketty" coders are out there. Maybe be as many as half a billion or more.

Read in the past, the early release of FORTRAN took 20 people 7 years to write, resulting in accumulated 140 years to complete. Can only imagine a lifetime passing in code compared to my own brief experiences.

WebPilot
Posts: 3716
Joined: Tue Dec 07, 2004 6:51 pm
Antipspambot question: 0
Location: 41d 1' N 80d 22' W

### Re: Back to Basic

I learned FORTRAN first in order to program mainframes.

I learned BASIC in order to program a Tektronix graphics workstation and those home pcs that had the code burned into their ROMs.

I've been wingin' it ever since.

WebPilot
Posts: 3716
Joined: Tue Dec 07, 2004 6:51 pm
Antipspambot question: 0
Location: 41d 1' N 80d 22' W

### Re: Back to Basic

Having read my other thread, Computing volume … estimating cycle freq, you know I moved on to C.

PyroJoe
Posts: 1743
Joined: Wed Aug 29, 2007 5:44 pm
Antipspambot question: 125
Location: Texas

### Re: Back to Basic

C was somewhat the defining line, better programmers picked it up, many had disdain. I could not tolerate the taste of C, only writing a few programs.

It was tragic how many BASIC programmers dropped out of the game after C.

Ghrey
Posts: 286
Joined: Fri Feb 15, 2008 8:41 am
Antipspambot question: 125
Location: Studio City, California
Contact:

### Re: Back to Basic

<<< Darth Vader sound effects on >>>

I am still here.

<<< Darth Vader sound effects off >>>

In all seriousness though it is some what astounding how much has been done with BASIC.

Thanks for the blast from the past guys.
In the process of moving, from the glorified phone booth we had to the house we have.

No real time to work on jets, more space, no time.

Life still complicated.

PyroJoe
Posts: 1743
Joined: Wed Aug 29, 2007 5:44 pm
Antipspambot question: 125
Location: Texas

### Re: Back to Basic

Found an old QBASIC.exe in my archives. downloaded the above code, renamed code3.txt to code3.bas, opened it in QBASIC and ran "as is". The results looked good except the code had some "!" marks.
Attachments

WebPilot
Posts: 3716
Joined: Tue Dec 07, 2004 6:51 pm
Antipspambot question: 0
Location: 41d 1' N 80d 22' W

### Re: Back to Basic

I installed this compiler yesterday.

It seems to be 21st century, industrial strength, multi-platform and backwards compatible with Qbasic. I have further testing to do.

WebPilot
Posts: 3716
Joined: Tue Dec 07, 2004 6:51 pm
Antipspambot question: 0
Location: 41d 1' N 80d 22' W

### Re: Back to Basic

There are some interesting graphics examples provided with the software that I got to work. I'll have to see if I can somehow get one or two up here.

The above is one frame from an extraordinary animation of
what is known as the Julia set.

Ghrey
Posts: 286
Joined: Fri Feb 15, 2008 8:41 am
Antipspambot question: 125
Location: Studio City, California
Contact:

### Re: Back to Basic

I Recently installed Gambas on my Linux box, and the power supply died, but it seems to be a sort of Vbasic for real programers....

Take a look.
In the process of moving, from the glorified phone booth we had to the house we have.

No real time to work on jets, more space, no time.

Life still complicated.

Ghrey
Posts: 286
Joined: Fri Feb 15, 2008 8:41 am
Antipspambot question: 125
Location: Studio City, California
Contact:

### Re: Back to Basic

That graphic did not come up ::BEFORE:: I posted just .After.

Fractal animation in BASIC << Darth Vader voice on >> Impressive << Darth Vader voice off >>

Seems worth a look, when I get a new PS....

Oh wait this Mac still works!!!!
In the process of moving, from the glorified phone booth we had to the house we have.

No real time to work on jets, more space, no time.

Life still complicated.