[xquery-talk] Literal NaN
David Lee
dlee at calldei.com
Fri Feb 25 10:29:11 PST 2011
Today I ran into yet a new hole in my xquery knowledge. (I guess I'm a
sponge !)
I needed to check if a value was numeric or not. I found the functx
function
http://www.xqueryfunctions.com/xq/functx_is-a-number.html
The code is interesting :
define function is-a-number
( $value as xdt:anyAtomicType? ) as xs:boolean {
fn:string(fn:number($value)) != 'NaN'
}
I'm wondering why this hand-standing ? Why cant I compare to NaN directly ?
Is there no literal constructor for NaN ? I cant find any . and my obvious
attempts fail like
If( number("abc") eq NaN ) .
Its just strange to me to have a value which can be returned by a function
which you cant construct .
Or have to use conversion to string , or maybe something equally obtuse
number("NaN") eq number( non-numeric-value )
----------------------------------------
David A. Lee
<mailto:dlee at calldei.com> dlee at calldei.com
<http://www.xmlsh.org> http://www.xmlsh.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://x-query.com/pipermail/talk/attachments/20110225/57183c96/attachment-0001.htm
More information about the talk
mailing list