SECTION B - PRIMER FILE : PRIMER.B MATHEMATICS *********** Mallard Basic supports a good range of mathematical functions, which means that it can be used for technical and accountancy programs when required. This section deals with simple arithmetic only; addition,subtraction, division and multiplication. This is essential knowledge, and if this is all you need don't bother to go any further. More information can be found in the advanced section if you need it, but knowledge of maths is required We look first at the operators (signs) for the four basic func- tions; addition + ,subtraction - , division /,and multiplication *. The first two will be familiar (+ and -) but the other two may be a little strange. The * may be completely new, but the / is the same as in a fraction 3/4, which is, after all, a division sum. This is only a passing comment ,as BASIC does not work in fractions, only decimals ( although fractions such as 6, (, 7 ,) can be printed) We saw,in section A that numbers can be printed alone or inside double quote marks. The difference shows in this section. If you print " 6+4" you get 6+4 on the screen , but leave out the quote marks and the computer works out the sum for you .You will see in the listing that follows how to make good use of this to write complete sums such as 6+4= 10. MALLARD BASIC does it's arithmetic in the same way as us, which is not true of all languages. In other words you don't need to learn new tricks. It also uses standard protocol; that is if you are doing a sum with mixed operators, it will do multiplication and division first, then addition and subtraction. If you want things done in a different order, you use brackets , as you would normally do. For example (6+4)*3= 30 ; but 6+4*3=18. A snag with MALLARD BASIC (which it shares with most calculators) is that large and small numbers are printed as scaled numbers (scientific format) Thus 0.042 decimal might be shown 4.2E-2 which means 4.2 x(10 to the power of -2). This probably won't bother you as the range of unscaled (ordinary decimal) numbers is quite wide. Floating point is supported too; that is you can put in decimal numbers with varying decimal places and the computor will accept and process them :for example 34.2 : 234.347 : 0.04, etc., but note that leading and trailing zeros are discarded ;that is 45.340 will print as 45.34 and 007 will print as 7. If you need to print this type of number it must be surrounded by quote marks. e.g "007" but then it can't be processed mathematically, because the computer will recognise it only as a string. Numbers can be entered and printed in columns with the decimal points in line as is often needed when making tables for statistical work or dealing with sums of money. This is known as formatted printing and is touched on briefly in this section. The listings which follow are designed to illustrate the points mentioned above. Please experiment as much as you like, as described in the file INTRO.D. Don't take anything for granted but try it for yourself. End of file PRIMER.B ing for granted but try it for yourself.