本文整理了Java中java.lang.Float.floatToIntBits()
方法的一些代码示例,展示了Float.floatToIntBits()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Float.floatToIntBits()
方法的具体详情如下:
包路径:java.lang.Float
类名称:Float
方法名:floatToIntBits
[英]Returns an integer corresponding to the bits of the given IEEE 754 single precision float value. All Not-a-Number (NaN) values are converted to a single NaN representation ( 0x7fc00000) (compare to #floatToRawIntBits).
[中]返回与给定IEEE 754单精度浮点值的位相对应的整数。所有*非数字(NaN)*值都转换为单个NaN表示(0x7fc00000)(与#floatorawintbits比较)。
代码示例来源:origin: apache/incubator-dubbo
/**
* to byte array.
*
* @param v value.
* @param b byte array.
* @param off array offset.
*/
public static void float2bytes(float v, byte[] b, int off) {
int i = Float.floatToIntBits(v);
b[off + 3] = (byte) i;
b[off + 2] = (byte) (i >>> 8);
b[off + 1] = (byte) (i >>> 16);
b[off + 0] = (byte) (i >>> 24);
}
代码示例来源:origin: apache/incubator-dubbo
/**
* to byte array.
*
* @param v value.
* @param b byte array.
* @param off array offset.
*/
public static void float2bytes(float v, byte[] b, int off) {
int i = Float.floatToIntBits(v);
b[off + 3] = (byte) i;
b[off + 2] = (byte) (i >>> 8);
b[off + 1] = (byte) (i >>> 16);
b[off + 0] = (byte) (i >>> 24);
}
代码示例来源:origin: libgdx/libgdx
public int hashCode () {
int h = 1;
for (int i = 0, n = size; i < n; i++)
h = h * 31 + Float.floatToIntBits(nodes[i].value);
return h;
}
代码示例来源:origin: libgdx/libgdx
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + Float.floatToIntBits(x);
result = prime * result + Float.floatToIntBits(y);
result = prime * result + Float.floatToIntBits(z);
return result;
}
代码示例来源:origin: libgdx/libgdx
/**
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() { // automatically generated by Eclipse
final int prime = 31;
int result = 1;
result = prime * result + Float.floatToIntBits(x);
result = prime * result + Float.floatToIntBits(y);
return result;
}
代码示例来源:origin: libgdx/libgdx
public int hashCode () {
int h = 1;
for (int i = 0, n = size; i < n; i++)
h = h * 31 + Float.floatToIntBits(nodes[i].value);
return h;
}
代码示例来源:origin: PhilJay/MPAndroidChart
/**
* {@inheritDoc}
*/
@Override
public int hashCode() {
return Float.floatToIntBits(width) ^ Float.floatToIntBits(height);
}
}
代码示例来源:origin: libgdx/libgdx
public static int floatToIntBits (float value) {
return Float.floatToIntBits(value);
}
代码示例来源:origin: libgdx/libgdx
public static int floatToIntBits (float value) {
return Float.floatToIntBits(value);
}
代码示例来源:origin: libgdx/libgdx
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
Vec3 other = (Vec3) obj;
if (Float.floatToIntBits(x) != Float.floatToIntBits(other.x)) return false;
if (Float.floatToIntBits(y) != Float.floatToIntBits(other.y)) return false;
if (Float.floatToIntBits(z) != Float.floatToIntBits(other.z)) return false;
return true;
}
代码示例来源:origin: libgdx/libgdx
/**
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) { // automatically generated by Eclipse
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
Vec2 other = (Vec2) obj;
if (Float.floatToIntBits(x) != Float.floatToIntBits(other.x)) return false;
if (Float.floatToIntBits(y) != Float.floatToIntBits(other.y)) return false;
return true;
}
}
代码示例来源:origin: libgdx/libgdx
public int hashCode () {
if (!ordered) return super.hashCode();
float[] items = this.items;
int h = 1;
for (int i = 0, n = size; i < n; i++)
h = h * 31 + Float.floatToIntBits(items[i]);
return h;
}
代码示例来源:origin: libgdx/libgdx
public int hashCode () {
if (!ordered) return super.hashCode();
float[] items = this.items;
int h = 1;
for (int i = 0, n = size; i < n; i++)
h = h * 31 + Float.floatToIntBits(items[i]);
return h;
}
代码示例来源:origin: libgdx/libgdx
public int hashCode () {
int h = 0;
K[] keyTable = this.keyTable;
float[] valueTable = this.valueTable;
for (int i = 0, n = capacity + stashSize; i < n; i++) {
K key = keyTable[i];
if (key != null) {
h += key.hashCode() * 31;
float value = valueTable[i];
h += Float.floatToIntBits(value);
}
}
return h;
}
代码示例来源:origin: google/guava
/**
* Writes a {@code float} as specified by {@link DataOutputStream#writeFloat(float)}, except using
* little-endian byte order.
*
* @throws IOException if an I/O error occurs
*/
@Override
public void writeFloat(float v) throws IOException {
writeInt(Float.floatToIntBits(v));
}
代码示例来源:origin: commons-io/commons-io
/**
* Converts a "float" value between endian systems.
* @param value value to convert
* @return the converted value
*/
public static float swapFloat(final float value) {
return Float.intBitsToFloat( swapInteger( Float.floatToIntBits( value ) ) );
}
代码示例来源:origin: commons-io/commons-io
/**
* Writes a "float" value to a byte array at a given offset. The value is
* converted to the opposed endian system while writing.
* @param data target byte array
* @param offset starting offset in the byte array
* @param value value to write
*/
public static void writeSwappedFloat(final byte[] data, final int offset, final float value) {
writeSwappedInteger( data, offset, Float.floatToIntBits( value ) );
}
代码示例来源:origin: commons-io/commons-io
/**
* Writes a "float" value to an OutputStream. The value is
* converted to the opposed endian system while writing.
* @param output target OutputStream
* @param value value to write
* @throws IOException in case of an I/O problem
*/
public static void writeSwappedFloat(final OutputStream output, final float value)
throws IOException
{
writeSwappedInteger( output, Float.floatToIntBits( value ) );
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void nullSafeHashCodeWithFloatArray() {
int expected = 31 * 7 + Float.floatToIntBits(9.6f);
expected = 31 * expected + Float.floatToIntBits(7.4f);
float[] array = {9.6f, 7.4f};
int actual = ObjectUtils.nullSafeHashCode(array);
assertEquals(expected, actual);
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testFloatArrayAsObject() {
final float[] obj = new float[2];
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
obj[0] = 5.4f;
final int h1 = Float.floatToIntBits(5.4f);
assertEquals((17 * 37 + h1) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
obj[1] = 6.3f;
final int h2 = Float.floatToIntBits(6.3f);
assertEquals((17 * 37 + h1) * 37 + h2, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
}
内容来源于网络,如有侵权,请联系作者删除!