You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Paul Barry <pa...@nyu.edu> on 2005/04/21 00:00:46 UTC

comparing long values

If I have the following code in a velocity template:

#if($myNumber > 0) yes # else no #end

If $myNumber is an Integer, it works, but if it is a Long, it doesn't. 
Is there any way to check if a Long is greater or less than an int?

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: comparing long values

Posted by Shinobu Kawai <sh...@gmail.com>.
Hi Paul,

> If I have the following code in a velocity template:
> 
> #if($myNumber > 0) yes # else no #end
> 
> If $myNumber is an Integer, it works, but if it is a Long, it doesn't.
> Is there any way to check if a Long is greater or less than an int?

Long arithmetic will be available from 1.5.  Which you need to get
from the nightly snapshots or build it from source.
    http://jakarta.apache.org/velocity/install.html

As a 1.4 solution, (haven't tried, but) you might be able to use compareTo.
    #if($myNumber.compareTo(0) > 0) yes # else no #end

Best regards,
-- Shinobu

--
Shinobu Kawai <sh...@gmail.com>

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org