7088952: Add size in bytes constant "BYTES" to primitive type wrapper types
Adds a constant BYTES to each of the primitive wrapper classes (Byte, Character, Double, Float, Integer, Long, Short) with the calculation Primitive.SIZE / Byte.SIZE already made. Reviewed-by: dholmes
This commit is contained in:
parent
78499292e1
commit
b2926d9724
@ -507,6 +507,14 @@ public final class Byte extends Number implements Comparable<Byte> {
|
||||
*/
|
||||
public static final int SIZE = 8;
|
||||
|
||||
/**
|
||||
* The number of bytes used to represent a {@code byte} value in two's
|
||||
* complement binary form.
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
public static final int BYTES = SIZE / Byte.SIZE;
|
||||
|
||||
/** use serialVersionUID from JDK 1.1. for interoperability */
|
||||
private static final long serialVersionUID = -7183698231559129828L;
|
||||
}
|
||||
|
@ -7170,6 +7170,14 @@ class Character implements java.io.Serializable, Comparable<Character> {
|
||||
*/
|
||||
public static final int SIZE = 16;
|
||||
|
||||
/**
|
||||
* The number of bytes used to represent a {@code char} value in unsigned
|
||||
* binary form.
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
public static final int BYTES = SIZE / Byte.SIZE;
|
||||
|
||||
/**
|
||||
* Returns the value obtained by reversing the order of the bytes in the
|
||||
* specified <tt>char</tt> value.
|
||||
|
@ -122,6 +122,13 @@ public final class Double extends Number implements Comparable<Double> {
|
||||
*/
|
||||
public static final int SIZE = 64;
|
||||
|
||||
/**
|
||||
* The number of bytes used to represent a {@code double} value.
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
public static final int BYTES = SIZE / Byte.SIZE;
|
||||
|
||||
/**
|
||||
* The {@code Class} instance representing the primitive type
|
||||
* {@code double}.
|
||||
|
@ -120,6 +120,13 @@ public final class Float extends Number implements Comparable<Float> {
|
||||
*/
|
||||
public static final int SIZE = 32;
|
||||
|
||||
/**
|
||||
* The number of bytes used to represent a {@code float} value.
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
public static final int BYTES = SIZE / Byte.SIZE;
|
||||
|
||||
/**
|
||||
* The {@code Class} instance representing the primitive type
|
||||
* {@code float}.
|
||||
|
@ -1297,6 +1297,14 @@ public final class Integer extends Number implements Comparable<Integer> {
|
||||
*/
|
||||
public static final int SIZE = 32;
|
||||
|
||||
/**
|
||||
* The number of bytes used to represent a {@code int} value in two's
|
||||
* complement binary form.
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
public static final int BYTES = SIZE / Byte.SIZE;
|
||||
|
||||
/**
|
||||
* Returns an {@code int} value with at most a single one-bit, in the
|
||||
* position of the highest-order ("leftmost") one-bit in the specified
|
||||
|
@ -1319,6 +1319,14 @@ public final class Long extends Number implements Comparable<Long> {
|
||||
*/
|
||||
public static final int SIZE = 64;
|
||||
|
||||
/**
|
||||
* The number of bytes used to represent a {@code long} value in two's
|
||||
* complement binary form.
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
public static final int BYTES = SIZE / Byte.SIZE;
|
||||
|
||||
/**
|
||||
* Returns a {@code long} value with at most a single one-bit, in the
|
||||
* position of the highest-order ("leftmost") one-bit in the specified
|
||||
|
@ -470,6 +470,14 @@ public final class Short extends Number implements Comparable<Short> {
|
||||
*/
|
||||
public static final int SIZE = 16;
|
||||
|
||||
/**
|
||||
* The number of bytes used to represent a {@code short} value in two's
|
||||
* complement binary form.
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
public static final int BYTES = SIZE / Byte.SIZE;
|
||||
|
||||
/**
|
||||
* Returns the value obtained by reversing the order of the bytes in the
|
||||
* two's complement representation of the specified {@code short} value.
|
||||
|
Loading…
x
Reference in New Issue
Block a user