Built-in Constants

Home • Gallery • Tutorials • Download • Purchase • Site Map

Built-in Program Constants

The following Fractal Science Kit program constants are pre-defined:

True        = 1
False       = 0
Math.PI     = 3.14159265358979
Math.E      = 2.71828182845905
Math.Phi    = 1.61803398874989
Math.2PI    = 2 * Math.PI
Math.PIdiv2 = Math.PI / 2
Math.1divPI = 1 / Math.PI
Infinity    = Infinity
NaN         = NaN

True and False are Boolean constants for true and false. Math.PI and Math.E are approximations for the mathematical constants pi and e, respectively. Math.Phi approximates the golden ratio. Infinity is a constant that represents an infinite value. NaN (Not a Number) is used to set a variable to value when no number is appropriate (e.g., 0/0) and usually indicates an error condition.

A word of warning: the constants True and False are provided to increase code clarity when assigning a value to a Boolean variable or passing a value to a function or method that takes a Boolean argument. It is ill advised to compare a Boolean variable directly to the constant True since the correct comparison is to check for any non-0 value.

Avoid direct comparisons with constants True or False as in:

if (state = True) {

if (state = False) {

Use the following instead:

if (state) {

if (~state) {


Copyright © 2004-2016 Hilbert, LLC
All rights reserved