Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#1216 closed defect (invalid)

Rasql returns -inf when divide by 0

Reported by: Bang Pham Huu Owned by:
Priority: major Milestone: 10.0
Component: rasql Version: development
Keywords: error divide by zero Cc: Dimitar Misev
Complexity: Medium

Description

WCPS query

for c in (eobstest) return encode(c[t(0:20), Lat(0:0), Long(25:65)] /0, "csv")

which returns

{{-inf},{-inf},{-inf},{-inf},{-inf},{-inf},{-inf},{-inf},{-inf},{-inf},{-inf},{-inf},{-inf},{-inf},{-inf},{-inf},{-inf},{-inf},{-inf},{-inf},{-inf},{-inf},{-inf},{-inf},{-inf},{-inf},{-inf},{-inf},{-inf},{-inf},{-inf},{-inf},{-inf},{-inf},

I think an exception in Rasql to know error divide by 0 is better?

Change History (6)

comment:1 by Dimitar Misev, 9 years ago

Resolution: invalid
Status: newclosed

comment:2 by Bang Pham Huu, 9 years ago

Resolution: invalid
Status: closedreopened

Dimitar, with returns "inf", it makes a very misunderstanding behavior, see this WCPS
query

for s in ( rgb) return encode(count((s.0)/(s.1) > 200), "csv") 

this returns {4220} values > 200 ( you can see from query and see it impossible by the "devide" operator ), but I don't know why this happen, only when I encode it in "csv" and count exactly 4200 "inf" values then I consider this is problem.

I think when devide by zero, it should be set to null in the value ( you can close it again but tell me what should I do in this case above ?)

comment:3 by Dimitar Misev, 9 years ago

In this query where you do aggregation, you don't need to encode the output in csv. This is better:

for s in ( rgb) return count((s.0)/(s.1) > 200)

Well inf is bigger than 200, that sounds correct to me?

comment:4 by Bang Pham Huu, 9 years ago

yes thanks for comment with encoding, but I think in some case when user need to count some point > some value (e.g counts how many vegetation point in satellite images), if it > 2000 then this images is good or < 2000 is bad, then in this case this will make user to have false decision by their believe in the outcome of WCPS query (I think user will want to have smaller points have real value than more points but have inf values).

:)

comment:5 by Dimitar Misev, 9 years ago

Resolution: invalid
Status: reopenedclosed

Bang, this is what the IEEE 754 specifies, and is exactly what C/C++ follows as well. If user wants to ignore the division by zero they can use a switch statement.

comment:6 by Bang Pham Huu, 9 years ago

ok, what I need to know is a solution in this way, thanks.

Note: See TracTickets for help on using tickets.