There was an error while loading. Please reload this page.
Create a row with this timestamp: 1337-09-02 11:43:21.622894 UTC, query and use fieldValue.getTimestamp(). Microseconds wouldn't be equal.
@test public void testFloatingPointPrecisionLoss() { FieldValue fieldValue = FieldValue.of(Attribute.PRIMITIVE, "-1.9954383398377106E10"); long received = fieldValue.getTimestampValue(); long expected = -19954383398377106L; assertEquals(expected, received); }
Cause - floating point conversation causes it; need to use BigDecimal (or equivalent) to perform lossless conversion.
Environment details
General, Core, and Other are also allowed as types
Steps to reproduce
Create a row with this timestamp: 1337-09-02 11:43:21.622894 UTC, query and use fieldValue.getTimestamp(). Microseconds wouldn't be equal.
Code example
@test
public void testFloatingPointPrecisionLoss() {
FieldValue fieldValue = FieldValue.of(Attribute.PRIMITIVE, "-1.9954383398377106E10");
long received = fieldValue.getTimestampValue();
long expected = -19954383398377106L;
assertEquals(expected, received);
}
Any additional information below
Cause - floating point conversation causes it; need to use BigDecimal (or equivalent) to perform lossless conversion.