That will truncate, leaving you with zero decimal places, not two.
This expression:

  #((num * 100) \ 1) / 100#

will do as you want, but it has the effect of truncating at two
decimal places, rather than rouding to two decimal places.  E.g.,
123.4567 will become 123.45, rather than the desired 123.46.  Not to
mention the fact that the round() call is much more readable.

cheers,
barneyb

On 4/3/07, Peter Boughton <[EMAIL PROTECTED]> wrote:
> You can avoid the round function by doing integer division:
>
> #num*100\100#
>
> >#round(num * 100) / 100# will do just the math part.  I.e. it won't
> >add commas for thousand separators or an extra trailing zero.  If you
> >need to round the number and get a number (rather than a display
> >string), this method is preferable.  That code is obviously suitable
> >for any number of decimal places, you need to raise 10 to the power of
> >the number of places you want and use it where I've used 100 (which is
> >10 ^ 2).
> >
> >cheers,
> >barneyb
> >

-- 
Barney Boisvert
[EMAIL PROTECTED]
http://www.barneyb.com/

Got Gmail? I have 100 invites.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create robust enterprise, web RIAs.
Upgrade & integrate Adobe Coldfusion MX7 with Flex 2
http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJP

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:274455
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to