On 10/19/01, Tilbrook, Peter penned:
>Hi there!
>
>I need to find the percentage of a value in ColdFusion but have been
>getting inconsistent results.
>
>eg:
>
>Initial Weight: 250 grams
>Weight Change: 10.7%
>Final Weight (would be 250 grams plus 10.7%): ??
>
>and also for subtracting (weight reduction), eg:
>
>Initial Weight: 250 grams
>Weight Change: -15.4%
>Final Weight (would be 250 grams minus 15.4%): ??

This should work for addition or subtraction. This is figuring you're 
passing the percent as a whole number (10 for 10%, not .1).

<cfset num = 250>
<cfset percent = "-15.4">

<CFOUTPUT>
#evaluate(num + (num * (percent / 100)))#
</CFOUTPUT>
-- 

Bud Schneehagen - Tropical Web Creations

_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
ColdFusion Solutions / eCommerce Development
[EMAIL PROTECTED]
http://www.twcreations.com/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to