MSX BASIC – lesson 2

da | Nov 18, 2023 | MSX BASIC | 0 comments

“MSX BASIC” COLUMN by Orazio Cacciola (part 2)

The Integer, Single and Double Precision Functions

As we know, numbers are the main basis of calculators, without them they would not exist. Therefore, we need to know how to distinguish them for a good performance of our programs and above all to make them faster. In fact, if we use decimal numbers in programs where there is no need, in addition to taking up more space in memory, it will slow down our programs.

Our MSX recognizes 3 types of numeric variables: Integer, Single Precision Real and Double Precision Real.

The integers occupy 2 bytes of memory and range from –32768 to 32767 and have the percent (%) as their classifier. They can be named at the beginning of the program with the function DEF INT [Initial variable letter] – [Final variable letter], that is, if we put the letter C in the first position and the letter V in the second, all the variables which, as the first character, will fall into them, they will be classified as integer variables. The rest, given that by default our MSX classifies the variables as double precision real, will be of the latter type.

Single precision real, they occupy 4 bytes and can display 6 digits after the decimal point, the recognition symbol is the exclamation point (!). Like integers, they can be named at the beginning of the program with the DEF SNG function. Everything else is as explained above for integers.

Double precision real, they occupy 8 bytes and can display 14 digits after the decimal point, the symbol that distinguishes them from the others is the pound sign (#) and they can be named at the beginning of the program with the DEF DBL function. Also for this reason, everything else is like the other 2 functions.
Given my little information on the size of real numbers, I quote what I read in the book I have; “Mc Graw Hill, The MSX Manual,” which says they need to be between 10 to the top -64 to 10 to the top +63.

Very importantly, if you use the variable classification symbols instead of defining them at the beginning of the program with the DEF function, remember to always insert this last saying, because if you forget it is omitted, our MSX will "see" them as 2 different variables. For example, if we use an integer variable (A%=100) and want to increment it; A%=A+1, the second variable A, since it does not have the symbol, the MSX will consider it as another variable and therefore if it has not been used in other parts of the program its value will be zero.

The next explanation will be on binary, octal and hexadecimal numbers.
Thanks to everyone and see you next time
Orazio Cacciola.

0 Comments

Submit a Comment

Your email address will not be published. I campi obbligatori sono contrassegnati *

LEZIONE 26 – INTERVAL ON, RND ED ALTRI

LESSON 26 – INTERVAL ON, RND AND OTHERS

Good morning everyone, In this episode I will talk about an important interrupt, especially for games, when we want to make an enemy suddenly appear or a useful object, but also to create a stopwatch or a clock and many other things. The COMMAND exploits the...

LEZIONE 26 – INTERVAL ON, RND ED ALTRI

LESSON 24 – THE DATA MANAGED BY THE MSX (PART 3)

Kind regards to everyone. Today we will close this topic, I will talk about direct or random access files. But first, as I mentioned in the last episode, I will give a small explanation about the program. First of all, the first thing to say is that I used a command which...