Chapter 3 DynaScript Predefined Objects
Enables you to use methods and obtain properties on a number.
Standard: ECMAScript
To use a Number property:
Number.propertyName
To use a Number method:
Number.MethodName( parameter )
The Number object represents a number for which
you want to use methods and properties made available with the Number
object. These methods and properties are not available to numbers
that are held by variables ( num = 14
).
You can call a Number object as a function:
Number( value );
or as a constructor:
myNumber = new Number( value );
When called as a function, a type conversion is performed and a number is returned. A new Number object is not created. When a Number object is created through a constructor, a Number object is returned.
The Number object has both a built-in object as well as constructors that allow users to create instances of a Number object. When referring to Number in the syntax sections of this chapter, we are referring to an instance of a Number object, not the built-in Number object.
This example creates a Number object with the value of 32:
<!--SCRIPT num = new Number( 32 ); document.WriteLn( num ); -->
Number.MAX_VALUE
This property is read-only.
Returns the largest positive finite value of the number type, which is approximately 1.7976931348623157e308.
Integer
This example displays the largest possible number that can be used in PowerDynamo:
<!--SCRIPT document.WriteLn( Number.MAX_VALUE ); -->
Number.MIN_VALUE
This property is read-only.
Returns the smallest positive nonzero value of the number type, which is approximately 5e-324.
Integer
This example displays the smallest positive nonzero number that can be used in PowerDynamo:
<!--SCRIPT document.WriteLn( Number.MIN_VALUE ); -->
Number.NaN
This property is read-only.
A value that indicates that an arithmetic expression returned a value that was not a number.
String (NaN)
This example has an output of NaN.
<!--SCRIPT document.WriteLn( Number.NaN ); -->
Number.NEGATIVE_INFINITY
This property is read-only.
Returns a string indicating that a number is outside the range that ECMAScript is capable of representing.
String (-Infinity)
This example has an output of -Infinity
:
<!--SCRIPT document.WriteLn( Number.NEGATIVE_INFINITY ); -->
Number.POSITIVE_INFINITY
This property is read-only.
Returns a string indicating that a number is outside the range that ECMAScript is capable of representing.
String (Infinity)
This example has an output of Infinity
:
<!--SCRIPT document.WriteLn( Number.POSITIVE_INFINITY ); -->
Number.toString( [radix] )
Returns a string representation of the Number object. You can use a radix if you want to work with something other than base 10.
String
This example creates a number object and converts the value to a string:
<!--SCRIPT num = new Number( 16 ); stringNum = num.toString(); document.WriteLn( stringNum ); -->
Number.valueOf( )
Extracts the number value of the number object as an integer.
Integer
This example creates a number object, and then
converts it back to an integer, which is held in the variable intNum
.
<!--SCRIPT num = new Number( 16 ); intNum = num.valueOf(); document.WriteLn( intNum ); -->
Copyright © 2001 Sybase, Inc. All rights reserved. |
![]() |