You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by jill han <jh...@bynum.com> on 2005/05/03 17:47:15 UTC

How to compare float number

I tried to compare a  float number to a certain value like:
#set($afloat=$floatObject.float)
#set($count = 0)
#if ($afloat >= 4)
	#set($count = $count + 1)
#end

But it was always evaluated as false, $count is always 0.

Thanks in advance.



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


Re: How to compare float number

Posted by Will Glass-Husain <wg...@forio.com>.
The unreleased Velocity 1.5-dev (grab the nightly snapshot of the source 
code) handles floats and all other number types.

Best,
WILL

----- Original Message ----- 
From: "Peter Harrison" <pe...@nothingbutnet.co.nz>
To: "Velocity Users List" <ve...@jakarta.apache.org>
Sent: Tuesday, May 03, 2005 1:52 PM
Subject: Re: How to compare float number


> On Wednesday 04 May 2005 03:47, jill han wrote:
>> I tried to compare a  float number to a certain value like:
>> #set($afloat=$floatObject.float)
>> #set($count = 0)
>> #if ($afloat >= 4)
>> #set($count = $count + 1)
>> #end
>>
>> But it was always evaluated as false, $count is always 0.
>
> Velocity doesn't deal with floats. I think velocity tools might have a 
> class
> for float math which you can add to the context for doing math.
>
> We developed our own math class along with date, comparitor and other 
> classes
> for dealing with these types of thing. I can probably post a link tot he 
> code
> at some point.
>
>
> -- 
> Peter Harrison
> Managing Director
> Nothing But Net Limited
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> 


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


Re: How to compare float number

Posted by Peter Harrison <pe...@nothingbutnet.co.nz>.
On Wednesday 04 May 2005 03:47, jill han wrote:
> I tried to compare a  float number to a certain value like:
> #set($afloat=$floatObject.float)
> #set($count = 0)
> #if ($afloat >= 4)
> 	#set($count = $count + 1)
> #end
>
> But it was always evaluated as false, $count is always 0.

Velocity doesn't deal with floats. I think velocity tools might have a class 
for float math which you can add to the context for doing math.

We developed our own math class along with date, comparitor and other classes 
for dealing with these types of thing. I can probably post a link tot he code 
at some point.


-- 
Peter Harrison
Managing Director
Nothing But Net Limited

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