DavidS wrote: ↑
Wed Jul 17, 2019 3:32 pm
While it is true that a floating point value can hold a integral value greater than 2^32-1, that is still being stored as a floating point value.
You seem to like to concentrate on implementation detail, when that shouldn't matter to the programmer. Regardless of how it's stored, it's an integer! But in any case what you state there is not true of my BASICs: going right back to BBC BASIC (Z80)
, when an integer value is stored in a suffixless variable like 'a' it isn't
stored in floating point format! Strictly such variables are not 'floats' but 'variants' in my versions, and you will find them referred to as such in the documentation
And you are the first I have ever heard call a floating point variable an ordinary variable, most seem to consider the integer variables the ordinary type.
BASIC traditionally has only two variable types, numeric and string. 'Integer variables', of the sort that BBC BASIC has, are a relatively new-fangled extension and some BASICs even today don't have them (for example Liberty BASIC). So I feel very strongly that the 'suffixless' numeric variable is the 'normal' type. In all early versions of BBC BASIC there wasn't even any saving in memory by using a (scalar) integer variable: the saving in one byte of storage (32-bits rather than 40) was exactly matched by the additional '%' suffix character! Of course there is a memory saving with arrays.
So BASIC V and up allow better positive range of variables than the older BBC BASICs?
No, BASIC 5 is the same as earlier versions; BASIC 6 (BASIC64) was the first to increase the range.
In BASIC V an integer variable may be treated as unsigned, thus allowing for values up to 2^32-1 (4294967295).
Where do you get that idea from? Integer variables are signed, just as they are in all other versions of BBC BASIC. An unsigned integer variable would need to have a different suffix character. You appear to have 'invented' a feature that it has never had!
And hence the reason that the manuals for BBC BASIC are very clear about returning an integer type (with all its limits) from certain functions like INT(
I know they're "clear", but it is no less silly. Sophie didn't often get things wrong, but this is one occasion when she did. You didn't answer my supplementary question so I will ask it again: since truncating a value like 2^50+0.5
to an integer is clearly a perfectly sensible thing to want to do, how would you code that in ARM BASIC 6? In BBC BASIC for Windows
and BBC BASIC for SDL 2.0
you simply use the INT function.