Arithmetic errors with casting between floats and ints

this is on version 0.2.130.post1-c69cd67afb8b

it seems that in some scenarios, casting back and forth between ints and floats can create arithmetic errors, presumably due to some error occurring during the casting.

minimal example:
create a very small hail table

with open("test.tsv","w") as f:
    f.write("A\n")
    f.write("2.44e-04\n")

read in as table

test_ht = hl.import_table("test.tsv", types={'A':hl.tfloat})

do some arithmetic

(hl.log10(test_ht.A) + 4).collect() 

—> [0.3873898263387292]

cast to an int

hl.int(hl.log10(test_ht.A) + 4).collect()

—> [0]

cast back to a float

hl.float(hl.int(hl.log10(test_ht.A) + 4)).collect()

—> [0.3873898263387292]
???

casting to a float32 seems to work correctly

hl.float32(hl.int(hl.log10(test_ht.A) + 4)).collect()

—> [0]

but doing the original cast to an int64 doesn’t

hl.float(hl.int64(hl.log10(test_ht.A) + 4)).collect()

→ [0.3873898263387292]

and doing this outside the table also works fine

hl.float(hl.int(hl.log10(hl.float(2.44e-4)) + 4)).collect()

—> [0]

it looks like in certain scenarios hl.float is effectively being treated as somehow inverting hl.int

Hi @Christopher_Kachulis,
Thanks for reporting this with code that reproduces the issue. This is a bug and I’ve created arithmetic errors with casting between floats and ints · Issue #14868 · hail-is/hail · GitHub from your description.
Thanks again,