Built-in Constants |
|
Built-in Program ConstantsThe following Fractal Science Kit program constants are pre-defined: True = 1 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) { Use the following instead: if (state) { |
Copyright © 2004-2019 Ross Hilbert |