intel MCS BASIC-52 — Intel MCS BASIC-52 Versions 1 & 1.1 Operating and Reference Manual PDF (EN)

int e l 5.2.1 UNARY OPERATORS -- GENERAL PURPOSE SQR([expr]) Returns the square root of the argument. The argument may not be less than zero. The result returned will be accurate to within + / - a value of 5 on the least significant digit. EXAMPLES: PRINT SQR(9) PRINT SQR(45) PRINT SQR(100) 3 6.7082035 10 RND Returns a pseudo-random number in the range between 0 and 1 inclusive. The RND operator uses a 16- bit binary seed and generates 65536 pseudo-random numbers before repeating the sequence. The numbers generated are specifically between 0/65535 and 65535/65535 inclusive. Unlike most BASICS, the RND operator in MCS BASIC-52 does not require an argument or a dummy argument.

In fact, if an argument is placed after the RND operator, a BAD SYNTAX error will occur. EXAMPLES: PRINT RND .30278477 PI PI is not really an operator, it is a stored constant. In MCS BASIC-52, PI is stored as 3.1415926. Math experts will notice that PI is actually closer to 3.141592653, so proper rounding for PI should yield the number 3.1415927. The reason MCS BASIC-52 uses a 6 instead of a 7 for the last digit is that errors in the SIN, COS and TAN operators were found to be greater when the 7 was used instead of 6. This is because the number PI/2 is needed for these calculations and it is desirable, for the sake of accuracy to have the equation PI/2 + PI/2 = PI hold true.

This cannot be done if the last digit in PI is an odd number, so the last digit of PI was rounded to 6 instead of 7 to make these calculations more accurate. - 77 -