Float — 플로트 래퍼 클래스
Float — 플로트 래퍼 클래스
Float 클래스는 원시 타입 float의 값을 객체로 감쌉니다. Float 타입의 객체는 타입이 float인 단일 필드를 포함합니다. 또한 이 클래스는 float를 String으로, String을 float로 변환하는 여러 메서드와 그 외 float 처리에 유용한 상수·메서드를 제공합니다.
본문
이 클래스는 값 기반 클래스(value-based class)이므로, 프로그래머는 동일한 인스턴스를 서로 교환 가능하게 취급해야 하며 동기화에 인스턴스를 사용해서는 안 됩니다. 그렇게 하면 예측할 수 없는 동작이 발생할 수 있습니다.
부동소수점 값의 동일성·동치·비교에 대한 논의는 java.lang.Double 클래스에 수록되어 있으며, 이는 float 값에도 동일하게 적용됩니다.
public final class Float extends Number
implements Comparable<Float>, Constable, ConstantDesc
주요 필드
public static final float POSITIVE_INFINITY
public static final float NEGATIVE_INFINITY
public static final float NaN
public static final float MAX_VALUE
public static final float MIN_VALUE
public static final float MIN_NORMAL
public static final int SIZE // 32
public static final int PRECISION
public static final int MAX_EXPONENT
public static final int MIN_EXPONENT
public static final int BYTES // 4
public static final Class<Float> TYPE
주요 메서드
public static String toString(float f)
public static String toHexString(float f)
public static Float valueOf(String s) throws NumberFormatException
public static float parseFloat(String s) throws NumberFormatException
public static boolean isNaN(float v)
public static boolean isInfinite(float v)
public static boolean isFinite(float f)
public float floatValue()
public static int floatToIntBits(float value)
public static float intBitsToFloat(int bits)
public static float float16ToFloat(short floatBinary16)
public static short floatToFloat16(float f)
public static int compare(float f1, float f2)
public static float sum(float a, float b)
public static float max(float a, float b)
public static float min(float a, float b)
Java 20부터 IEEE 754 반정밀도(float16)와 단정밀도(float) 간의 변환 메서드(float16ToFloat, floatToFloat16)가 제공됩니다.