I'm trying to negate a double precision value inside jsonb data. I had to cast it to double since PG will return it as text. I found that zero value are printed as -0
Is that fine? how to fix it without "CASE WHEN"
I'm trying to negate a double precision value inside jsonb data. I had to cast it to double since PG will return it as text. I found that zero value are printed as -0
Is that fine? how to fix it without "CASE WHEN"
As @Bergi asked: What is the problem? The properties of 0 and -0 are exactly the same. Run:
select '0 vs. -0. they are ' ||
case when ( 0 = -0)
then 'Equal'
else 'Not Equal'
end;
Also see demo here. In all cases the results are the same. Multiplication produces -0 instead of 0, but since they are the same they can be freely substituted.