DarkBASIC has several useful math commands; I will go over the basic ones here. Later in this chapter, I’ll explain the more advanced math commands.

The `SQRT` command is short for “square root.” The square root of a number X is the value which, when multiplied by itself, results in the number X. The square root is the opposite of a number raised to the second power (`N ^ 2`). Consider an earlier example, 10×10 = 100. The square root of 100 is 10, or rather `SQRT(100) = 10`. Remember that this differs from exponents in general in that the square root only applies to a squared number. Here is an example:

A = 100 B = SQRT(A) PRINT "The square root of "; A; " is "; B; "."

The `ABS` command returns the absolute ...

Start Free Trial

No credit card required