@Status(stage=PRODUCTION, unitTests=COMPLETE) @Review(by="Kees Schotanus", at="2009-09-28") @ThreadSafety(level=IMMUTABLE) public final class CShort extends Number implements Comparable<CShort>
Short
is that
this class has support for arithmetic operations that protect against both
underflow and overflow.Short
is final so this class extends
class Number
instead. This class is immutable and contains private
constructors in combination with static factory methods as suggested by
Joshua Bloch (Effective Java, Second Edition, item 15).Modifier and Type | Method and Description |
---|---|
CShort |
add(short value)
Adds the supplied value to this value.
|
static short |
add(short x,
short y)
Adds y to x.
|
byte |
byteValue()
Returns the value of this CShort as a byte.
|
int |
compareTo(CShort object)
Compares two CShort objects numerically.
|
CShort |
divide(short value)
Divides this value by the supplied value.
|
static short |
divide(short x,
short y)
Divides x by y.
|
CShort |
divideAndFloor(short value)
Divides this value by the supplied value and floors the result.
|
static short |
divideAndFloor(short x,
short y)
Divides x by y and floors the result.
|
double |
doubleValue()
Returns the value of this CShort as a double.
|
boolean |
equals(Object object)
Determines whether this object and the supplied object are the same.
|
float |
floatValue()
Returns the value of this CShort as a float.
|
int |
hashCode()
Computes the hash code value for this object.
|
int |
intValue()
Returns the value of this CShort as an int.
|
long |
longValue()
Returns the value of this CShort as a long.
|
CShort |
multiply(short value)
Multiplies this value by the supplied value.
|
static short |
multiply(short x,
short y)
Multiplies x by y.
|
short |
shortValue()
Returns the value of this CShort as a short.
|
CShort |
subtract(short value)
Subtracts the supplied value from this value.
|
static short |
subtract(short x,
short y)
Subtracts y from x.
|
String |
toString()
Converts the stored primitive short value to a String.
|
static CShort |
valueOf(long value)
Returns a CShort object holding the value of the supplied value.
|
static CShort |
valueOf(Number value)
Returns a CShort object holding the value of the supplied value.
|
static CShort |
valueOf(short value)
Returns a CShort object holding the value of the supplied value.
|
static CShort |
valueOf(String value)
Returns a CShort object holding the parsed value of the supplied value.
|
public byte byteValue()
public short shortValue()
shortValue
in class Number
public int intValue()
public long longValue()
public float floatValue()
floatValue
in class Number
public double doubleValue()
doubleValue
in class Number
public static CShort valueOf(short value)
value
- The short value.public static CShort valueOf(long value)
value
- The long value.IllegalArgumentException
- When the supplied value is not in the
range: [Short.MIN_VALUE
to Short.MAX_VALUE
].public static CShort valueOf(Number value)
value
- The Number that holds the value.NullPointerException
- When the supplied value is null.IllegalArgumentException
- When the supplied value is not in the
range: [Short.MIN_VALUE
to Short.MAX_VALUE
].public static CShort valueOf(String value)
value
- The String that is parsed.IllegalArgumentException
- When the supplied value (after parsing)
is not in the range:
[Short.MIN_VALUE
to Short.MAX_VALUE
].NumberFormatException
- When the supplied value does not contain a
parsable short (this includes a null or empty value).Short.parseShort(String)
public boolean equals(Object object)
public int hashCode()
public int compareTo(CShort object)
compareTo
in interface Comparable<CShort>
object
- CShort object to compare with this object.NullPointerException
- When the supplied object is null.Comparable
public CShort add(short value)
value
- Value to add to the stored value.ArithmeticException
- When an arithmetic underflow or overflow
occurs.add(short, short)
public static short add(short x, short y)
x
- Operand one.y
- Operand two.ArithmeticException
- When an arithmetic underflow or overflow
occurs.public CShort subtract(short value)
value
- Value to subtract from the stored value.ArithmeticException
- When an arithmetic underflow or overflow
occurs.subtract(short, short)
public static short subtract(short x, short y)
x
- Operand one.y
- operand two.ArithmeticException
- When an arithmetic underflow or overflow
occurs.public CShort multiply(short value)
value
- Value to multiply by the stored value.ArithmeticException
- When an arithmetic underflow or overflow
occurs.multiply(short, short)
public static short multiply(short x, short y)
x
- Operand one.y
- Operand two.ArithmeticException
- When an arithmetic underflow or overflow
occurs.public CShort divide(short value)
value
- Value by which this value will be divided.ArithmeticException
- When an arithmetic overflow occurs or when
the supplied value is 0.divide(short, short)
public static short divide(short x, short y)
x
- Operand one.y
- Operand two.ArithmeticException
- When an arithmetic overflow occurs or when
the supplied y value is 0.public CShort divideAndFloor(short value)
value
- Value by which this value will be divided.ArithmeticException
- When an arithmetic overflow occurs or when
the supplied value is 0.divideAndFloor(short, short)
public static short divideAndFloor(short x, short y)
x
- Operand one.y
- Operand two.ArithmeticException
- When an arithmetic overflow occurs or when
the supplied y value is 0.Copyright © 2008–2018. All rights reserved.