Page 1 of 1

What is so bad about using Floating Point math in a BASIC program

Posted: Sun Mar 24, 2019 3:18 am
by Crayon21
I understand the ZX80 and 81 are simple machine. What I do not understand is the 32768 limitation and how it affects programs. The Apple II had this issue, making it hard to program business programs. What I want to know is Why?

please help a confused novice programmer

Re: What is so bad about using Floating Point math in a BASIC program

Posted: Sun Mar 24, 2019 11:58 am
by dr beep
It is slow, even in the display of a number.

I recently coded USCII and ran the same program in pure ZX81 BASIC and with USCII which only does a different way of displaying a number.
It only accepts a positive rounded number to be printed. Even with this change only the ZX81 BASIC is twice as fast as normal BASIC.
https://www.youtube.com/watch?v=rwzcrSbIJkk

Re: What is so bad about using Floating Point math in a BASIC program

Posted: Mon Mar 25, 2019 11:50 pm
by Crayon21
but how exactly is it slow? I can see the video just fine. my question concerns the hardware. for instance, creating a business application using just FP numbers and no Integers. how would they be different, what would the change look like when run?

Re: What is so bad about using Floating Point math in a BASIC program

Posted: Tue Mar 26, 2019 9:30 am
by 1024MAK
If you had to take a child to school by road, would you use a gas guzzling posh 4x4 or a fuel efficient modern small car?

Floating point numbers are the “jack of all trades” and can cope with a very wide range of numbers. But there are some potential disadvantages. They only store approximations (because internally in a computer all numbers are stored as binary digits, and converting from/to decimal can result in rounding errors), they take up more bytes of memory than simpler integral numbers, it takes time for the computer to convert from/to a floating point number, or to carry out mathematical operations on a floating point number.

Integral numbers are more limited. They also have various disadvantages, but have some advantages. Within the range, whole (integral decimal numbers convert very easily to/from binary. They are faster to process when adding or subtracting etc. They take up less memory.

They come in a number of different types:
One byte can store a decimal number between 0 and 255, or between -128 and +127 depending on how the the operator handles the number.
Two bytes can store a decimal number between 0 and 65535, or between -32768 and +32767 depending on how the the operator handles the number.
There are larger ranges available on computers with more memory.

Mark