Problem with Variable having Numericvalue node comparison
Wednesday, 13 May 2015 · 4 messages
AK
ankit kumar13 May 2015 09:40 #
Hi,
I am trying to compare two variable in basex as given,
let $v3 :=<a>7900000.00</a>
let $v2:=<a>930000.00</a>
return $v2 <= $v3I am expecting that it will give me true, But it is giving false. I think it is because of the comparison is only string comparison. Is it possible to configure basex for numeric comparison without changing the expression $V2 <= $V3 , or I have to explicitly convert variable value to decimal and then compare it.
Thanks,
Ankit
CG
Christian Grün13 May 2015 09:43 #
Simply convert the values to numbers:
let $v3 :=<a>7900000.00</a>
let $v2:=<a>930000.00</a>
return number($v2) <= number($v3)Best,
Christian
Quoted text · ankit kumar · 18 lines
On Wed, May 13, 2015 at 9:40 AM, ankit kumar <anky4bugs at gmail.com> wrote: > Hi, > > I am trying to compare two variable in basex as given, > > let $v3 :=<a>7900000.00</a> > let $v2:=<a>930000.00</a> > return $v2 <= $v3 > > I am expecting that it will give me true, But it is giving false. I think it > is because of the comparison is only string comparison. Is it possible to > configure basex for numeric comparison without changing the expression $V2 > <= $V3 , or I have to explicitly convert variable value to decimal and then > compare it. > > > Thanks, > Ankit
AK
ankit kumar13 May 2015 10:00 #
Thanks for your reply.
Actually, The comparison expression is coming from other side. So changing the expression is not possible for me.
Thanks,
Ankit
Quoted text · ankit kumar · 19 lines
On 13 May 2015 at 13:18, Marco Lettere <marco.lettere at dedalus.eu> wrote: > On 13/05/2015 09:40, ankit kumar wrote: > >> let $v3 :=<a>7900000.00</a> >> let $v2:=<a>930000.00</a> >> return $v2 <= $v3 >> > > Hi Ankit, > > is the following: > > let $v3 :=<a>7900000.00</a> > let $v2:=<a>930000.00</a> > return xs:float($v2) <= xs:float($v3) > > too much of a change for your use-case? > M. >
CG
Christian Grün13 May 2015 10:01 #
Who is the other side? What can you change?
Quoted text · ankit kumar · 31 lines
On Wed, May 13, 2015 at 10:00 AM, ankit kumar <anky4bugs at gmail.com> wrote: > Thanks for your reply. > > Actually, The comparison expression is coming from other side. So changing > the expression is not possible for me. > > > Thanks, > Ankit > > On 13 May 2015 at 13:18, Marco Lettere <marco.lettere at dedalus.eu> wrote: >> >> On 13/05/2015 09:40, ankit kumar wrote: >>> >>> let $v3 :=<a>7900000.00</a> >>> let $v2:=<a>930000.00</a> >>> return $v2 <= $v3 >> >> >> Hi Ankit, >> >> is the following: >> >> let $v3 :=<a>7900000.00</a> >> let $v2:=<a>930000.00</a> >> return xs:float($v2) <= xs:float($v3) >> >> too much of a change for your use-case? >> M. > >
Written for BaseX 8.1. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery