Skip to content

Commit

Permalink
more code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
cloud-fan committed Nov 26, 2018
1 parent 8a9103c commit 7c590bc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,14 @@ public void writeMinusZeroIsReplacedWithZero() {
byte[] floatBytes = new byte[Float.BYTES];
Platform.putDouble(doubleBytes, Platform.BYTE_ARRAY_OFFSET, -0.0d);
Platform.putFloat(floatBytes, Platform.BYTE_ARRAY_OFFSET, -0.0f);
double doubleFromPlatform = Platform.getDouble(doubleBytes, Platform.BYTE_ARRAY_OFFSET);
float floatFromPlatform = Platform.getFloat(floatBytes, Platform.BYTE_ARRAY_OFFSET);

Assert.assertEquals(Double.doubleToLongBits(0.0d), Double.doubleToLongBits(doubleFromPlatform));
Assert.assertEquals(Float.floatToIntBits(0.0f), Float.floatToIntBits(floatFromPlatform));
byte[] doubleBytes2 = new byte[Double.BYTES];
byte[] floatBytes2 = new byte[Float.BYTES];
Platform.putDouble(doubleBytes, Platform.BYTE_ARRAY_OFFSET, 0.0d);
Platform.putFloat(floatBytes, Platform.BYTE_ARRAY_OFFSET, 0.0f);

// Make sure the bytes we write from 0.0 and -0.0 are same.
Assert.assertArrayEquals(doubleBytes, doubleBytes2);
Assert.assertArrayEquals(floatBytes, floatBytes2);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -334,17 +334,11 @@ public void setLong(int ordinal, long value) {
}

public void setFloat(int ordinal, float value) {
if (Float.isNaN(value)) {
value = Float.NaN;
}
assertIndexIsValid(ordinal);
Platform.putFloat(baseObject, getElementOffset(ordinal, 4), value);
}

public void setDouble(int ordinal, double value) {
if (Double.isNaN(value)) {
value = Double.NaN;
}
assertIndexIsValid(ordinal);
Platform.putDouble(baseObject, getElementOffset(ordinal, 8), value);
}
Expand Down

0 comments on commit 7c590bc

Please sign in to comment.