x10.lang
Class Int

x10.lang.Int
All Implemented Interfaces:
Any

public struct class Int
implements Any, Comparable<Int>, Arithmetic<Int>, Bitwise<Int>, Ordered<Int>, Any

Int is a 32-bit signed two's complement integral data type, with values ranging from -2147483648 to 2147483647, inclusive. All of the normal arithmetic and bitwise operations are defined on Int, and Int is closed under those operations. There are also static methods that define conversions from other data types, including String, as well as some Int constants.


Field Summary
static Int MIN_VALUE
          Field Type: x10.lang.Int{self==-2147483648} A constant holding the minimum value an Int can have, -231.
static Int MAX_VALUE
          Field Type: x10.lang.Int{self==2147483647} A constant holding the maximum value an Int can have, 231-1.
 
Constructor Summary
Int()
          
 
Method Summary
 Boolean operator<(Int x)
          A less-than operator.
 Boolean operator>(Int x)
          A greater-than operator.
 Boolean operator<=(Int x)
          A less-than-or-equal-to operator.
 Boolean operator>=(Int x)
          A greater-than-or-equal-to operator.
 Int operator+(Int x)
          A binary plus operator.
 Int operator-(Int x)
          A binary minus operator.
 Int operator*(Int x)
          A binary multiply operator.
 Int operator/(Int x)
          A binary divide operator.
 Int operator%(Int x)
          A binary remainder operator.
 Int operator+()
          A unary plus operator.
 Int operator-()
          A unary minus operator.
 Int operator&(Int x)
          A bitwise and operator.
 Int operator|(Int x)
          A bitwise or operator.
 Int operator^(Int x)
          A bitwise xor operator.
 Int operator<<(Int count)
          A bitwise left shift operator.
 Int operator>>(Int count)
          A bitwise right shift operator.
 Int operator>>>(Int count)
          Deprecated. use the right-shift operator and unsigned conversions instead.
 Int operator~()
          A bitwise complement operator.
static Int implicit_operator_as(Byte x)
          Coerce a given Byte to an Int.
static Int implicit_operator_as(Short x)
          Coerce a given Short to an Int.
static Int operator_as(Long x)
          Convert a given Long to an Int.
static Int operator_as(Float x)
          Convert a given Float to an Int.
static Int operator_as(Double x)
          Convert a given Double to an Int.
static Int operator_as(UInt x)
          Coerce a given UInt to an Int.
 String toString(Int radix)
          Returns a String representation of this Int in the specified radix.
 String toHexString()
          Returns a String representation of this Int as a hexadecimal number.
 String toOctalString()
          Returns a String representation of this Int as an octal number.
 String toBinaryString()
          Returns a String representation of this Int as a binary number.
 String toString()
          Returns a String representation of this Int as a decimal number.
static Int parseInt(String s, Int radix)
          Deprecated. use parse(String,Int) instead
static Int parseInt(String s)
          Deprecated. use parse(String) instead
static Int parse(String s, Int radix)
          Parses the String argument as an Int in the radix specified by the second argument.
static Int parse(String s)
          Parses the String argument as a decimal Int.
 Int highestOneBit()
          Returns an Int value with at most a single one-bit, in the position of the highest-order ("leftmost") one-bit in this Int value.
 Int lowestOneBit()
          Returns an Int value with at most a single one-bit, in the position of the lowest-order ("rightmost") one-bit in this Int value.
 Int numberOfLeadingZeros()
          Returns the number of zero bits preceding the highest-order ("leftmost") one-bit in the two's complement binary representation of this Int.
 Int numberOfTrailingZeros()
          Returns the number of zero bits following the lowest-order ("rightmost") one-bit in the two's complement binary representation of this Int.
 Int bitCount()
          Returns the number of one-bits in the two's complement binary representation of this Int.
 Int rotateLeft(Int distance)
          Returns the value obtained by rotating the two's complement binary representation of this Int left by the specified number of bits.
 Int rotateRight(Int distance)
          Returns the value obtained by rotating the two's complement binary representation of this Int right by the specified number of bits.
 Int reverse()
          Returns the value obtained by reversing the order of the bits in the two's complement binary representation of this Int.
 Int signum()
          Returns the signum function of this Int.
 Int reverseBytes()
          Returns the value obtained by reversing the order of the bytes in the two's complement representation of this Int.
 Boolean equals(Any x)
          Return true if the given entity is an Int, and this Int is equal to the given entity.
 Boolean equals(Int x)
          Returns true if this Int is equal to the given Int.
 Int compareTo(Int x)
          Returns a negative Int, zero, or a positive Int if this Int is less than, equal to, or greater than the given Int.
static IntRange operator..(Int x, Int y)
          Declaration: operator..(x:x10.lang.Int,y:x10.lang.Int): x10.lang.IntRange{self.min==x, self.max==y}. Constructs a IntRange from the lower bound to the upper bound, inclusive.
 String typeName()
          
 Boolean _struct_equals(Any other)
          
 Boolean _struct_equals(Int other)
          
 Int x10$lang$Int$$x10$lang$Int$this()
          Declaration: x10$lang$Int$$x10$lang$Int$this(): x10.lang.Int{self==this(:x10.lang.Int)}. Int is a 32-bit signed two's complement integral data type, with values ranging from -2147483648 to 2147483647, inclusive.
 
Methods inherited from interface x10.lang.Comparable
compareTo
 
Methods inherited from interface x10.lang.Arithmetic
operator+, operator-, operator+, operator-, operator*, operator/
 
Methods inherited from interface x10.lang.Bitwise
operator~, operator&, operator|, operator^, operator<<, operator>>, operator>>>
 
Methods inherited from interface x10.util.Ordered
operator<, operator>, operator<=, operator>=
 
Methods inherited from interface x10.lang.Any
toString, typeName, equals, hashCode
 

Field Detail

MIN_VALUE

public static final Int MIN_VALUE
Field Type: x10.lang.Int{self==-2147483648}
A constant holding the minimum value an Int can have, -231.


MAX_VALUE

public static final Int MAX_VALUE
Field Type: x10.lang.Int{self==2147483647}
A constant holding the maximum value an Int can have, 231-1.

Constructor Detail

Int

public Int()

Method Detail

operator<

public final Boolean operator<(Int x)
A less-than operator. Compares this Int with another Int and returns true if this Int is strictly less than the other Int.

Parameters:
x - the other Int
Returns:
true if this Int is strictly less than the other Int.

operator>

public final Boolean operator>(Int x)
A greater-than operator. Compares this Int with another Int and returns true if this Int is strictly greater than the other Int.

Parameters:
x - the other Int
Returns:
true if this Int is strictly greater than the other Int.

operator<=

public final Boolean operator<=(Int x)
A less-than-or-equal-to operator. Compares this Int with another Int and returns true if this Int is less than or equal to the other Int.

Parameters:
x - the other Int
Returns:
true if this Int is less than or equal to the other Int.

operator>=

public final Boolean operator>=(Int x)
A greater-than-or-equal-to operator. Compares this Int with another Int and returns true if this Int is greater than or equal to the other Int.

Parameters:
x - the other Int
Returns:
true if this Int is greater than or equal to the other Int.

operator+

public final Int operator+(Int x)
A binary plus operator. Computes the result of the addition of the two operands. Overflows result in truncating the high bits.

Parameters:
x - the other Int
Returns:
the sum of this Int and the other Int.

operator-

public final Int operator-(Int x)
A binary minus operator. Computes the result of the subtraction of the two operands. Overflows result in truncating the high bits.

Parameters:
x - the other Int
Returns:
the difference of this Int and the other Int.

operator*

public final Int operator*(Int x)
A binary multiply operator. Computes the result of the multiplication of the two operands. Overflows result in truncating the high bits.

Parameters:
x - the other Int
Returns:
the product of this Int and the other Int.

operator/

public final Int operator/(Int x)
A binary divide operator. Computes the result of the division of the two operands.

Parameters:
x - the other Int
Returns:
the quotient of this Int and the other Int.

operator%

public final Int operator%(Int x)
A binary remainder operator. Computes a remainder from the division of the two operands.

Parameters:
x - the other Int
Returns:
the remainder from dividing this Int by the other Int.

operator+

public final Int operator+()
A unary plus operator. A no-op.

Returns:
the value of this Int.

operator-

public final Int operator-()
A unary minus operator. Negates the operand. Overflows result in truncating the high bits.

Returns:
the negated value of this Int.

operator&

public final Int operator&(Int x)
A bitwise and operator. Computes a bitwise AND of the two operands.

Parameters:
x - the other Int
Returns:
the bitwise AND of this Int and the other Int.

operator|

public final Int operator|(Int x)
A bitwise or operator. Computes a bitwise OR of the two operands.

Parameters:
x - the other Int
Returns:
the bitwise OR of this Int and the other Int.

operator^

public final Int operator^(Int x)
A bitwise xor operator. Computes a bitwise XOR of the two operands.

Parameters:
x - the other Int
Returns:
the bitwise XOR of this Int and the other Int.

operator<<

public final Int operator<<(Int count)
A bitwise left shift operator. Computes the value of the left-hand operand shifted left by the value of the right-hand operand. The shift count will be masked with 0x1f before the shift is applied.

Parameters:
count - the shift count
Returns:
this Int shifted left by count.

operator>>

public final Int operator>>(Int count)
A bitwise right shift operator. Computes the value of the left-hand operand shifted right by the value of the right-hand operand, replicating the sign bit into the high bits. The shift count will be masked with 0x1f before the shift is applied.

Parameters:
count - the shift count
Returns:
this Int shifted right by count.

operator>>>

public final Int operator>>>(Int count)
Deprecated. use the right-shift operator and unsigned conversions instead.

A bitwise logical right shift operator (zero-fill). Computes the value of the left-hand operand shifted right by the value of the right-hand operand, filling the high bits with zeros. The shift count will be masked with 0x1f before the shift is applied.

Parameters:
count - the shift count
Returns:
this Int shifted right by count with high bits zero-filled.

operator~

public final Int operator~()
A bitwise complement operator. Computes a bitwise complement (NOT) of the operand.

Returns:
the bitwise complement of this Int.

implicit_operator_as

public static final Int implicit_operator_as(Byte x)
Coerce a given Byte to an Int.

Parameters:
x - the given Byte
Returns:
the given Byte converted to an Int.

implicit_operator_as

public static final Int implicit_operator_as(Short x)
Coerce a given Short to an Int.

Parameters:
x - the given Short
Returns:
the given Short converted to an Int.

operator_as

public static final Int operator_as(Long x)
Convert a given Long to an Int.

Parameters:
x - the given Long
Returns:
the given Long converted to an Int.

operator_as

public static final Int operator_as(Float x)
Convert a given Float to an Int.

Parameters:
x - the given Float
Returns:
the given Float converted to an Int.

operator_as

public static final Int operator_as(Double x)
Convert a given Double to an Int.

Parameters:
x - the given Double
Returns:
the given Double converted to an Int.

operator_as

public static final Int operator_as(UInt x)
Coerce a given UInt to an Int.

Parameters:
x - the given UInt
Returns:
the given UInt converted to an Int.

toString

public final String toString(Int radix)
Returns a String representation of this Int in the specified radix.

Parameters:
radix - the radix to use in the String representation
Returns:
a String representation of this Int in the specified radix.

toHexString

public final String toHexString()
Returns a String representation of this Int as a hexadecimal number.

Returns:
a String representation of this Int as a hexadecimal number.

toOctalString

public final String toOctalString()
Returns a String representation of this Int as an octal number.

Returns:
a String representation of this Int as an octal number.

toBinaryString

public final String toBinaryString()
Returns a String representation of this Int as a binary number.

Returns:
a String representation of this Int as a binary number.

toString

public final String toString()
Returns a String representation of this Int as a decimal number.

Returns:
a String representation of this Int as a decimal number.

parseInt

public static final Int parseInt(String s,
                                 Int radix)
Deprecated. use parse(String,Int) instead


parseInt

public static final Int parseInt(String s)
Deprecated. use parse(String) instead


parse

public static final Int parse(String s,
                              Int radix)
Parses the String argument as an Int in the radix specified by the second argument.

Parameters:
s - the String containing the Int representation to be parsed
radix - the radix to be used while parsing s
Returns:
the Int represented by the String argument in the specified radix.
Throws:
NumberFormatException - if the String does not contain a parsable Int.

parse

public static final Int parse(String s)
Parses the String argument as a decimal Int.

Parameters:
s - the String containing the Int representation to be parsed
Returns:
the Int represented by the String argument.
Throws:
NumberFormatException - if the String does not contain a parsable Int.

highestOneBit

public final Int highestOneBit()
Returns an Int value with at most a single one-bit, in the position of the highest-order ("leftmost") one-bit in this Int value. Returns zero if this Int has no one-bits in its two's complement binary representation, that is, if it is equal to zero.

Returns:
an Int value with a single one-bit, in the position of the highest-order one-bit in this Int, or zero if this Int is itself equal to zero.

lowestOneBit

public final Int lowestOneBit()
Returns an Int value with at most a single one-bit, in the position of the lowest-order ("rightmost") one-bit in this Int value. Returns zero if this Int has no one-bits in its two's complement binary representation, that is, if it is equal to zero.

Returns:
an Int value with a single one-bit, in the position of the lowest-order one-bit in this Int, or zero if this Int is itself equal to zero.

numberOfLeadingZeros

public final Int numberOfLeadingZeros()
Returns the number of zero bits preceding the highest-order ("leftmost") one-bit in the two's complement binary representation of this Int. Returns 32 if this Int has no one-bits in its two's complement representation, in other words if it is equal to zero.

Returns:
the number of zero bits preceding the highest-order one-bit in the two's complement binary representation of this Int, or 32 if this Int is equal to zero.

numberOfTrailingZeros

public final Int numberOfTrailingZeros()
Returns the number of zero bits following the lowest-order ("rightmost") one-bit in the two's complement binary representation of this Int. Returns 32 if this Int has no one-bits in its two's complement representation, in other words if it is equal to zero.

Returns:
the number of zero bits following the lowest-order one-bit in the two's complement binary representation of this Int, or 32 if this Int is equal to zero.

bitCount

public final Int bitCount()
Returns the number of one-bits in the two's complement binary representation of this Int. This function is sometimes referred to as the population count.

Returns:
the number of one-bits in the two's complement binary representation of this Int.

rotateLeft

public final Int rotateLeft(Int distance)
Returns the value obtained by rotating the two's complement binary representation of this Int left by the specified number of bits. (Bits shifted out of the left hand, or high-order, side reenter on the right, or low-order.)
Note that left rotation with a negative distance is equivalent to right rotation: rotateLeft(val, -distance) == rotateRight(val, distance). Note also that rotation by any multiple of 32 is a no-op, so all but the last five bits of the rotation distance can be ignored, even if the distance is negative: rotateLeft(val, distance) == rotateLeft(val, distance & 0x1F).

Parameters:
distance - the distance to rotate by
Returns:
the value obtained by rotating the two's complement binary representation of this Int left by the specified number of bits.
See Also:
rotateRight(Int)

rotateRight

public final Int rotateRight(Int distance)
Returns the value obtained by rotating the two's complement binary representation of this Int right by the specified number of bits. (Bits shifted out of the right hand, or low-order, side reenter on the left, or high-order.)
Note that right rotation with a negative distance is equivalent to left rotation: rotateRight(val, -distance) == rotateLeft(val, distance). Note also that rotation by any multiple of 32 is a no-op, so all but the last five bits of the rotation distance can be ignored, even if the distance is negative: rotateRight(val, distance) == rotateRight(val, distance & 0x1F).

Parameters:
distance - the distance to rotate by
Returns:
the value obtained by rotating the two's complement binary representation of this Int right by the specified number of bits.
See Also:
rotateLeft(Int)

reverse

public final Int reverse()
Returns the value obtained by reversing the order of the bits in the two's complement binary representation of this Int.

Returns:
the value obtained by reversing order of the bits in this Int.

signum

public final Int signum()
Returns the signum function of this Int. The return value is -1 if this Int is negative; 0 if this Int is zero; and 1 if this Int is positive.

Returns:
the signum function of this Int.

reverseBytes

public final Int reverseBytes()
Returns the value obtained by reversing the order of the bytes in the two's complement representation of this Int.

Returns:
the value obtained by reversing the bytes in this Int.

equals

public final Boolean equals(Any x)
Return true if the given entity is an Int, and this Int is equal to the given entity.

Parameters:
x - the given entity
Returns:
true if this Int is equal to the given entity.

equals

public final Boolean equals(Int x)
Returns true if this Int is equal to the given Int.

Parameters:
x - the given Int
Returns:
true if this Int is equal to the given Int.

compareTo

public final Int compareTo(Int x)
Returns a negative Int, zero, or a positive Int if this Int is less than, equal to, or greater than the given Int.

Parameters:
x - the given Int
Returns:
a negative Int, zero, or a positive Int if this Int is less than, equal to, or greater than the given Int.

operator..

public static final IntRange operator..(Int x,
                                        Int y)
Declaration: operator..(x:x10.lang.Int,y:x10.lang.Int): x10.lang.IntRange{self.min==x, self.max==y}.
Constructs a IntRange from
the lower bound to the upper bound, inclusive.

Parameters:
lower - the lower bound
upper - the upper bound
Returns:
a range from lower to upper, inclusive.

typeName

public final String typeName()


_struct_equals

public final Boolean _struct_equals(Any other)


_struct_equals

public final Boolean _struct_equals(Int other)


x10$lang$Int$$x10$lang$Int$this

public final Int x10$lang$Int$$x10$lang$Int$this()
Declaration: x10$lang$Int$$x10$lang$Int$this(): x10.lang.Int{self==this(:x10.lang.Int)}.
Int is a 32-bit signed two's complement integral data type, with
values ranging from -2147483648 to 2147483647, inclusive.  All of the normal
arithmetic and bitwise operations are defined on Int, and Int
is closed under those operations.  There are also static methods
that define conversions from other data types, including String,
as well as some Int constants.