You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by "Skriloff, Nicholas" <Sk...@darden.virginia.edu> on 2005/06/06 16:48:41 UTC

compare float?

3 Questions:

1) We have been using velocity 1.3.1-rc2 and have a requirement where we
need to compare floats in velocity templates.  So we need to do
something like

 #set($afloat=$floatObject.gpa)

 #set($gpaWarning = 2.7)

 #if ($afloat <= $gpaWarning)

academic probation letter....

 

Can this be done in 1.5-dev?  If we need to put the gpaWarning value
into context, we can do that if it cannot be declared in the template.
Is that needed? 

 

2) We have quite a bit of code that depends on 1.3.1-rc2, is 1.5-dev in
a stable state? 

 

3) What is the URL to get the Velocity 1.5-dev version? 

 

--------------------------------------------------

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

> 

 

 

Sincerely,
Nick Skriloff, ME, MCP
Information Technology Specialist
Darden Information Services
Voice 434 243 5025  Fax 434 982 2741
skriloffn@darden.virginia.edu

 


Re: compare float?

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

> 1) We have been using velocity 1.3.1-rc2 and have a requirement where we
> need to compare floats in velocity templates.  So we need to do
> something like
> 
>  #set($afloat=$floatObject.gpa)
> 
>  #set($gpaWarning = 2.7)
> 
>  #if ($afloat <= $gpaWarning)
> 
> academic probation letter....
> 
> 
> 
> Can this be done in 1.5-dev?  If we need to put the gpaWarning value
> into context, we can do that if it cannot be declared in the template.
> Is that needed?

Yes it can, so no it's not.  As an alternative, you can create a
$floatObject.isGpaUnderWarningValue() method.  :)

> 2) We have quite a bit of code that depends on 1.3.1-rc2, is 1.5-dev in
> a stable state?

The developers are trying their best to keep the code base working.  I
would trust it, but it's up to you to decide.

> 3) What is the URL to get the Velocity 1.5-dev version?

http://cvs.apache.org/snapshots/velocity/

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