All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jangaroo-runtime.2.0.19.source-code.int.as Maven / Gradle / Ivy

There is a newer version: 4.1.8
Show newest version
package {

/**
 * The int class lets you work with the data type representing a 32-bit signed integer. The range of values represented by the int class is -2,147,483,648 (-2^31) to 2,147,483,647 (2^31-1).
 * 

The constant properties of the int class, MAX_VALUE and MIN_VALUE, are static, which means that you don't need an object to use them, so you don't need to use the constructor. The methods, however, are not static, which means that you do need an object to use them. You can create an int object by using the int class constructor or by declaring a variable of type int and assigning the variable a literal value.

*

The int data type is useful for loop counters and other situations where a floating point number is not needed, and is similar to the int data type in Java and C++. The default value of a variable typed as int is 0

*

If you are working with numbers that exceed int.MAX_VALUE, consider using Number.

*

The following example calls the toString() method of the int class, which returns the string 1234:

* * var myint:int = 1234; * myint.toString(); * *

The following example assigns the value of the MIN_VALUE property to a variable declared without the use of the constructor:

*
 * var smallest:int = int.MIN_VALUE;
 * 
*

View the examples

* @see uint * @see Number * @see http://help.adobe.com/en_US/as3/learn/WS5b3ccc516d4fbf351e63e3d118a9b90204-7f9c.html Data types * @see http://help.adobe.com/en_US/as3/learn/WS5b3ccc516d4fbf351e63e3d118a9b90204-7f88.html Data type descriptions * @see http://help.adobe.com/en_US/as3/learn/WS5b3ccc516d4fbf351e63e3d118a9b90204-7f87.html Type conversions * */ [Native] public final class int { /** * Constructor; creates a new int object. You must use the int constructor when using int.toString() and int.valueOf(). You do not use a constructor when using the properties of an int object. The new int constructor is primarily used as a placeholder. An int object is not the same as the int() function that converts a parameter to a primitive value. * When called as a function (not as constructor), converts a given numeric value to an integer value. Decimal values are truncated at the decimal point. * * @param num The numeric value of the int object being created or a value to be converted to a?number. The default value is 0 if value is not provided. * * @return The new integer object or the converted integer value. * * @see #toString() * @see #valueOf() * @see http://help.adobe.com/en_US/as3/learn/WS5b3ccc516d4fbf351e63e3d118a9b90204-7f9c.html Data types * @see http://help.adobe.com/en_US/as3/learn/WS5b3ccc516d4fbf351e63e3d118a9b90204-7f88.html Data type descriptions * @see http://help.adobe.com/en_US/as3/learn/WS5b3ccc516d4fbf351e63e3d118a9b90204-7f87.html Type conversions * * @example How to use this exampleThe following code constructs new int objects: *
   * var n1:int = new int(3.4);
   * var n2:int = new int(-10);
   * 
*/ public native function int(num:Object); /** * Returns a string representation of the number in exponential notation. The string contains one digit before the decimal point and up to 20 digits after the decimal point, as specified by the fractionDigits parameter. * @param fractionDigits An integer between 0 and 20, inclusive, that represents the desired number of decimal places. * * @return String * * @throws RangeError Throws an exception if the fractionDigits argument is outside the range 0 to 20. * * @example The following example shows how toExponential(2) returns a string in exponential notation. * * var num:Number = 315003; * trace(num.toExponential(2)); // 3.15e+5 * * */ public native function toExponential(fractionDigits:uint):String; /** * Returns a string representation of the number in fixed-point notation. Fixed-point notation means that the string will contain a specific number of digits after the decimal point, as specified in the fractionDigits parameter. The valid range for the fractionDigits parameter is from 0 to 20. Specifying a value outside this range throws an exception. * @param fractionDigits An integer between 0 and 20, inclusive, that represents the desired number of decimal places. * * @return String * * @throws RangeError Throws an exception if the fractionDigits argument is outside the range 0 to 20. * * @example The following example shows how toFixed(3) returns a string that rounds to three decimal places. * * var num:Number = 7.31343; * trace(num.toFixed(3)); // 7.313 * *
The following example shows how toFixed(2) returns a string that adds trailing zeroes. * * var num:Number = 4; * trace(num.toFixed(2)); // 4.00 *
*/ public native function toFixed(fractionDigits:uint):String; /** * Returns a string representation of the number either in exponential notation or in fixed-point notation. The string will contain the number of digits specified in the precision parameter. * @param precision An integer between 1 and 21, inclusive, that represents the desired number of digits to represent in the resulting string. * * @return String * * @throws RangeError Throws an exception if the precision argument is outside the range 1 to 21. * * @example The following example shows how toPrecision(3) returns a string with only three digits. The string is in fixed-point notation because exponential notation is not required. * * var num:Number = 31.570; * trace(num.toPrecision(3)); // 31.6 * *
The following example shows how toPrecision(3) returns a string with only three digits. The string is in exponential notation because the resulting number does not contain enough digits for fixed-point notation. * * var num:Number = 4000; * trace(num.toPrecision(3)); // 4.00e+3 *
*/ public native function toPrecision(precision:uint):String; /** * Returns the string representation of an int object. * @param radix Specifies the numeric base (from 2 to 36) to use for the number-to-string conversion. If you do not specify the radix parameter, the default value is 10. * * @return A string. * * @example How to use this exampleThe following example uses 2 and 8 for the radix parameter and returns a string that contains the corresponding representation of the number 9: *
   * var myint:int = new int(9);
   * trace(myint.toString(2)); // 1001
   * trace(myint.toString(8)); // 11
   * 
*

The following example results in a hexadecimal value.

*
   * var r:int = new int(250);
   * var g:int = new int(128);
   * var b:int = new int(114);
   * var rgb:String = "0x"+ r.toString(16)+g.toString(16)+b.toString(16);
   * trace(rgb); // 0xfa8072
   * 
*/ public native function toString(radix:uint = 10):String; /** * Returns the primitive value of the specified int object. * @return An int value. * * @example How to use this exampleThe following example results in the primative value of the numSocks object. *
   * var numSocks:int = new int(2);
   * trace(numSocks.valueOf()); // 2
   * 
*/ public native function valueOf():int; /** * The largest representable 32-bit signed integer, which is 2,147,483,647. * @example How to use this exampleThe following ActionScript displays the largest and smallest representable int objects to the Output panel: *
   * trace("int.MIN_VALUE = "+int.MIN_VALUE);
   * trace("int.MAX_VALUE = "+int.MAX_VALUE);
   * 
*

This code displays the following values:

*
   * int.MIN_VALUE = -2147483648
   * int.MAX_VALUE = 2147483647
   * 
*/ public static const MAX_VALUE:uint = 2147483647; /** * The smallest representable 32-bit signed integer, which is -2,147,483,648. * @example How to use this exampleThe following ActionScript displays the largest and smallest representable int objects to the Output panel: *
   * trace("int.MIN_VALUE = "+int.MIN_VALUE);
   * trace("int.MAX_VALUE = "+int.MAX_VALUE);
   * 
*

This code displays the following values:

*
   * int.MIN_VALUE = -2147483648
   * int.MAX_VALUE = 2147483647
   * 
*/ public static const MIN_VALUE:uint = -2147483648; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy