Value > Basic Data Values > Number Values |
The last three Number value classes are available in 3ds Max 9 and higher. Please see 64 Bit Values - Double, Integer64, IntegerPtr for details.
The Number class provides standard arithmetic capabilities to MAXScript. The Number types can be freely intermixed and MAXScript will convert as necessary.
Also see Number Literals.
[-]{<digit>}[(.{<digit>}[(e | E | d | D)[+ | -]{<digit>}+) | L | P] --decimal number 0x{<hex_digit>}+ --hexadecimal number
The number classes support the following operators and methods.
Standard arithmetic operations. If both numbers are integers, the result is a non-rounded integer. If one or both numbers are floats, both arguments are widened to floats and the result is a float.
Raise the first number to the power given by the second number. If the first number is an integer, the result is a rounded integer.
<number> == <number> <number> != <number> <number> > <number> <number> < <number> <number> >= <number> <number> <= <number>
Standard number comparison operations.
Converts the number to an instance of the given class. Allowed classes are:
Creates a new copy of the number value. This method exists primarily to support copying arrays.
Returns the absolute value of the number. The result is the same type as the argument.
Modulo arithmetic, the remainder when number1 is divided by number2 . The result is always a float.
Returns the nearest whole number greater than or equal to number . The result is always a float.
Returns the nearest whole number less than or equal to number . The result is always a float.
MAXScript supports the following standard trigonometric functions. Angles are represented in degrees. The result is always a float.
MAXScript supports the following standard transcendental functions. The result is always a float.
Natural logarithm of the argument.
Returns a pseudo random number inclusively between the two arguments. Return value type is the type of the first argument.
Reseeds the random number generator using the specified value.
Returns the conversion of the number from degrees to radians. The result is always a float.
Returns the conversion of the number from radians to degrees. The result is always a float.
Returns true if the two <float> values are approximately equal, where increasing values of <int> increase the range defined as approximately equal. Available in 3ds Max 2008 and higher. Previously available in the Avguard Extensions.
A good value of <int> in most cases is 10.
Returns the <integer> result of AND-ing the bits in integer1 and integer2
Returns the <integer> result of OR-ing the bits in integer1 and integer2
Returns the <integer> result of XOR-ing the bits in integer1 and integer2
Returns the <integer> result of flipping the bits in integer1
Returns the <integer> result of shifting the bits in integer1 by integer2 places. If integer2 is positive, the bits are shifted to the left, if negative, to the right. The highest order bit is not carried when shifting to the left (unsigned shift operation).
Returns an <integer> result where bit integer2 of integer1 is set to the specified boolean value. Bit 1 is the lowest order (least significant) bit.
Returns an <integer> result where bit integer2 of integer1 is flipped. Bit 1 is the lowest order (least significant) bit.
Returns the <boolean> state of the integer2 bit of integer1. Bit 1 is the lowest order (least significant) bit.
Returns a <string> result of length 1 containing the character corresponding to the integer value.
Only the lowest order 8-bits (16-bits for localized versions of 3ds Max) of the integer are used.
Returns the <integer> value corresponding to the first character of the string.
Returns a <string> value containing the hex representation of the integer.
Returns the integer value cast to a float value. Typically used for converting between integer and float values so that the remaining bit methods can be used on a float.
Available in 3ds Max 8 and higher.
Returns the float value cast to a integer value. Typically used for converting between integer and float values so that the remaining bit methods can be used on a float.
Available in 3ds Max 8 and higher.
Returns an integer with bytes byte1 and byte2 of value int swapped. Byte 1 is the lowest order byte.
Available in 3ds Max 8 and higher.
Returns true if the float is the reserved float value NAN (Not A Number). A NAN is generated when the result of a floating-point operation cannot be represented as a floating point number.
An example of NAN is f = (1.0/0.0).
Available in 3ds Max 8 and higher.
Returns true if the float is any value other than NaN, negative infinity, or positive infinity. In those three cases, it returns false.
Converts a Double value into an Integer64 value.
Converts an Integer64 value into a Double value.
The range of valid Integers in MAXScript is -2,147,483,648 to 2,147,483,647. If you perform calculations that result in integers outside of this range, you will get integer overflow errors thatare notdetected by MAXScript. You must take care in designing your code to prevent or detect this overflow yourself. The result of an overflow is typically a large number of the wrong sign. Dividing an integer by 0 will result in a MAXScript system exception.
AFloat in MAXScript has an absolute value range of is 1.18E-38 to 3.40E38, with a precision of one part in 1.0E7. If you perform calculations that result in floats with an absolute value less than this range, the result will be stored as 0.0. If you perform calculations that result in floats with an absolute value larger than this range, the result will be stored as a special value that represents infinity, 1.#INF . Adding, subtracting, or multiplying a number by 1.#INF results in a value of 1.#INF . Dividing a number by 1.#INF results in a value of 0.0. Dividing 0.0 by 0.0 or 1.#INF by 1.#INF , multiplying 1.#INF by 0, or 1.#INF from 1.#INF results in a special value that represents an indeterminate number, - 1.#IND . Adding, subtracting, multiplying, or dividing a number by - 1.#IND results in a value of - 1.#IND .
When you display or print a Float, MAXScript prints the value to the 6th significant digit. The following table shows examples of values stored to a MAXScript variable, the value as stored, and the value as displayed.