Class ApproximateValues
★ A FLOAT COLUMN HOLDS A DOUBLE. Live-verified on every write path — INSERT … VALUES, INSERT …
SELECT, UPDATE, MERGE, CTAS, a column DEFAULT, a text value, an integer — a value written into a
FLOAT column becomes the nearest double: a stored 0.1 reads back as
0.10000000000000000555 through ::NUMBER(38,20), a stored nineteen-digit integer
becomes 1234567890123456768, and a stored -0.0::FLOAT keeps its sign. Frostlake used
to keep whatever class the value arrived in, so the same column held a BigDecimal, a Long or a
Double depending on how the row was written, and every one of those cells disagreed with the account.
★ A FLOAT BESIDE AN EXACT NUMBER COMPARES AS A DOUBLE. Live answers TRUE for
1234567890123456789::FLOAT = 1234567890123456768 and for
0.1::FLOAT = 0.10000000000000000555: the exact side is converted to a double and the two
doubles are compared. Comparing through the double's shortest decimal spelling, as this engine did,
made both FALSE.
★ NEGATIVE ZERO IS A VALUE OF ITS OWN, and equal to zero. -0.0::FLOAT = 0.0::FLOAT is TRUE
and -0.0::FLOAT < 0 is FALSE, while a tie between the two keeps whichever was seen FIRST —
GREATEST, LEAST, MIN and MAX all answer -0 when it leads. ORDER BY is the one place with a
tie-break: -0 sorts before 0.
-
Method Summary
Modifier and TypeMethodDescriptionstatic intcompare(double left, double right) Two doubles compared as VALUES:-0.0and0.0are equal, so a tie keeps the first seen.static booleanisApproximate(Object value) Whether a runtime value is carried as a double.static intorder(double left, double right) Two doubles compared for SORTING, which is the one place the two zeros are told apart:-0sorts before0, as it does on the account.static DoubleThe double a value takes when written into an approximate column, or null when the value is not numeric text or a number at all (a boolean, a variant) and the caller keeps it as it is.
-
Method Details
-
written
The double a value takes when written into an approximate column, or null when the value is not numeric text or a number at all (a boolean, a variant) and the caller keeps it as it is.- Parameters:
value- the value as the write produced it- Returns:
- its double, or null
-
isApproximate
Whether a runtime value is carried as a double.- Parameters:
value- any value- Returns:
- true for a Double or a Float
-
compare
public static int compare(double left, double right) Two doubles compared as VALUES:-0.0and0.0are equal, so a tie keeps the first seen. NaN keeps its place in the total order — it equals itself and outranks everything.- Parameters:
left- one valueright- the other- Returns:
- negative, zero or positive
-
order
public static int order(double left, double right) Two doubles compared for SORTING, which is the one place the two zeros are told apart:-0sorts before0, as it does on the account.- Parameters:
left- one valueright- the other- Returns:
- negative, zero or positive
-