⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 float.java

📁 一个开源的JAVA虚拟机
💻 JAVA
字号:
/*    libaegisvm - The Aegis Virtual Machine for executing Java bytecode    Copyright (C) 2001-2002  Philip W. L. Fong    This library is free software; you can redistribute it and/or    modify it under the terms of the GNU Lesser General Public    License as published by the Free Software Foundation; either    version 2.1 of the License, or (at your option) any later version.    This library is distributed in the hope that it will be useful,    but WITHOUT ANY WARRANTY; without even the implied warranty of    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU    Lesser General Public License for more details.    You should have received a copy of the GNU Lesser General Public    License along with this library; if not, write to the Free Software    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA*/// java.lang.Float// (c) Peter Nagy// API version: 1.0.2// History://  1997-01-18 Initial version	Peter Nagy//  1997-02-25 modified		Glynn Clements <glynn@sensei.co.uk>package java.lang;public final class Float extends Number implements Comparable {    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 Class TYPE;    static {	POSITIVE_INFINITY = rawIntBitsToFloat(0x7f800000);	NEGATIVE_INFINITY = rawIntBitsToFloat(0xff800000);	NaN               = rawIntBitsToFloat(0x7fc00000);	MAX_VALUE         = rawIntBitsToFloat(0x7f7fffff);	MIN_VALUE         = rawIntBitsToFloat(0x1);	TYPE              = Class.getPrimitiveType(Class.T_FLOAT);    }    private float value;    public Float(float value) {	this.value = value;    }    public Float(double value) {	this.value = (float) value;    }    public Float(String s) throws NumberFormatException {	value = parseFloat(s);    }    /**     * \todo Need fix.     */    public static String toString(float v) {	return Double.toString(v);    }    public static Float valueOf(String s) throws NumberFormatException {	return new Float(s);    }    /**     * \todo Need fix.     */    public static float parseFloat(String s) throws NumberFormatException {	return (float) Double.parseDouble(s);    }    private static boolean isPositiveZero(float v) {	return (1.0f / v) == POSITIVE_INFINITY;    }    private static boolean isNegativeZero(float v) {	return (1.0f / v) == NEGATIVE_INFINITY;    }    public static boolean isNaN(float v) {	return v != v;    }    public static boolean isInfinite(float v) {	return (v == POSITIVE_INFINITY || v == NEGATIVE_INFINITY);    }    public boolean isNaN() {	return isNaN(value);    }    public boolean isInfinite() {	return isInfinite(value);    }    public String toString() {	return toString(value);    }    public byte byteValue() {	return (byte) value;    }    public short shortValue() {	return (short) value;    }    public int intValue() {	return (int) value;    }    public long longValue() {	return (long) value;    }    public float floatValue() {	return value;    }    public double doubleValue() {	return (double) value;    }    public int hashCode() {	return floatToIntBits(value);    }    public boolean equals(Object obj) {	return	    (obj instanceof Float) &&	    floatToIntBits(value) == floatToIntBits(((Float) obj).value);    }    public static int floatToIntBits(float value) {	if (isNaN(value))	    return 0x7fc00000;	return floatToRawIntBits(value);    }    public static native int floatToRawIntBits(float value);    public static float intBitsToFloat(int bits) {	if (bits >= 0x7f800001 && bits <= 0x7fffffff)	    return NaN;	if (bits >= 0xff800001 && bits <= 0xffffffff)	    return NaN;	return rawIntBitsToFloat(bits);    }    private static native float rawIntBitsToFloat(int bits);    public int compareTo(Float anotherFloat) {	float value2 = anotherFloat.value;	if (isNaN(value)) {	    if (isNaN(value2))		return 0;	    else		return 1;	} else if (isNaN(value2)) {	    return -1;	} else if (value == 0.0f && value2 == 0.0f) {	    if (1.0f / value == POSITIVE_INFINITY) {		if (1.0f / value2 == POSITIVE_INFINITY)		    return 0;		else		    return 1;	    } else {		if (1.0f / value2 == POSITIVE_INFINITY)		    return -1;		else		    return 0;	    }	} else {	    if (value > value2)		return 1;	    else if (value < value2)		return -1;	    else		return 0;	}    }    public int compareTo(Object o) {	return compareTo((Float) o);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -