O'Reilly logo

DarkBASIC Pro Game Programming, Second Edition by Joshua R. Smith, Jonathan S. Harbour

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Basic Math Commands

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.

Square Root

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; "."

Absolute Value

The ABS command returns the absolute ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required