[xquery-talk] avoid divide by zero

David Carlisle davidc at nag.co.uk
Thu May 25 10:40:19 PDT 2006


> I have a statement that might cause divide by zero, is
> there any statement to replace zero by one when it
> occurs. 

... div (let $x := ...... return if ($x = 0) then 1 else $x)

or if you know the expression is non-negative, as here, then more simply:

... div max((.... , 1))

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________


More information about the talk mailing list