deephaven / deephaven-core

Deephaven Community Core
Other
242 stars 78 forks source link

Losing differentiation intra-column between -0.0 and 0.0 #3751

Open devinrsmith opened 1 year ago

devinrsmith commented 1 year ago

In the following code, the double column "X" for t1 and t2 are correctly displayed, but only the first "X" for t3 and t4 are correct.

from deephaven import new_table
from deephaven.column import double_col

t1 = new_table([double_col("X", [0.0, 0.0])]).update_view("B=Double.doubleToLongBits(X)")
t2 = new_table([double_col("X", [-0.0, -0.0])]).update_view("B=Double.doubleToLongBits(X)")
t3 = new_table([double_col("X", [-0.0, 0.0])]).update_view("B=Double.doubleToLongBits(X)")
t4 = new_table([double_col("X", [0.0, -0.0])]).update_view("B=Double.doubleToLongBits(X)")

I've verified that the engine has the correct bit patterns (in the case of -0.0, it happens to have the bit pattern of NULL_LONG, but this is of no consequence except to show the bit patterns are different).

image

I've done a quick test, and it appears that do exchange is returning the correct data (testing w/ io.deephaven.client.examples.DoExchange):

Schema<X: FloatingPoint(DOUBLE), B: Int(64, true)>
X   B
-0.0    null
0.0 0

This leads me to believe it may be a JS or web UI rendering issue of some sort. (It is possible that the barrage data on the wire is incorrect in some circumstances, but I've not seen that w/ the java client.)

devinrsmith commented 1 year ago

"S=String.valueOf(X)" is also a good way to view the actual double

niloc132 commented 1 year ago

I think I've confirmed that the JS API is correctly returning a js number of -0 and 0. The HTML samples don't work - it looks like coercing that value to strings in various ways can cause issues, but the Column.get(Row) and Row.get(Column) do return the expected value.

The formatter html sample also doesn't work right (more bad coercing?), but the NumberFormat api appears to be correct too:

> dh.i18n.NumberFormat.format("###,###.0#", 0)
< ".0"
> dh.i18n.NumberFormat.format("###,###.0#", -0)
< "-.0"