Single v Double
#4
"SINGLE" type is like a holdover of 8-bit computers such as the Radio Shack TRS-80 Color Computer 2 which had only two types: "numeric" and string. It didn't care if the "numeric" was an integer, and it had five or six digits of floating-point precision. Use "SINGLE" when the programmer must have fractional quantities but the accuracy is coarse, such as small currency values.

"DOUBLE" was invented to try to do something about "SINGLE" not going far enough, yet it is dwarfed by types subsequently invented while we made the transition from 16-bit to 32-bit and then to 64-bit. M$ BASIC PDS v7.1 and VBDOS had "CURRENCY" type but that was somewhat confusing; internally it was stored as "LONG" (or maybe 64-bit integer?) but was shown to the user having four digits of fraction precision.

"_FLOAT" was supposed to be more precise than "DOUBLE" with very large and very small numbers. However, up to 17 places for an integer, "_INTEGER64" is better. As was looked up by Steve, numbers can never be accurate like scientists want because the internal system to store the numbers is base-2, at least for a general purpose computer.

Some people are dissatisfied with the accuracy from the existing floating-point types not being good enough and that's why we're seeing a lot of "string arithmetic" libraries going around.

For example, might want to look at this thread:

https://staging.qb64phoenix.com/showthre...11#pid8811

The way floating-point numbers are stored is necessary in other programming languages to have a value which is like negative infinity or "Not A Number". Then the powers that be decided there should have been "different" NaNs... it's better not to think much about it. In M$ BASIC, "SQR(-1)" always gave out error #5. In some other programming language it could return NaN. There has to be a value that represents it although it's "Not A Number", get it? BTW this is told apart from "complex number" library, this is just an example of how BASIC could react to an "illegal" value compared to a different programming language.
Reply


Messages In This Thread
Single v Double - by Dimster - 11-05-2022, 04:44 PM
RE: Single v Double - by Jack - 11-05-2022, 05:14 PM
RE: Single v Double - by Pete - 11-05-2022, 05:31 PM
RE: Single v Double - by mnrvovrfc - 11-05-2022, 05:43 PM
RE: Single v Double - by Jack - 11-05-2022, 06:00 PM
RE: Single v Double - by Dimster - 11-05-2022, 06:11 PM
RE: Single v Double - by Pete - 11-05-2022, 06:32 PM
RE: Single v Double - by Jack - 11-05-2022, 07:00 PM
RE: Single v Double - by Kernelpanic - 11-05-2022, 09:56 PM
RE: Single v Double - by mnrvovrfc - 11-05-2022, 10:10 PM
RE: Single v Double - by Pete - 11-05-2022, 10:48 PM
RE: Single v Double - by Jack - 11-05-2022, 11:46 PM
RE: Single v Double - by Kernelpanic - 11-05-2022, 11:50 PM
RE: Single v Double - by Pete - 11-05-2022, 11:59 PM
RE: Single v Double - by Jack - 11-06-2022, 12:35 AM
RE: Single v Double - by Pete - 11-06-2022, 12:38 AM
RE: Single v Double - by Kernelpanic - 11-06-2022, 02:03 AM
RE: Single v Double - by Richard - 11-06-2022, 12:42 AM
RE: Single v Double - by Pete - 11-06-2022, 02:07 AM



Users browsing this thread: 18 Guest(s)