Peter,

Here's some code that might help you get what you're after:

<cfset weight = 250>
<cfset percent_change = 107/1000>
<cfset final_weight = weight + (weight * percent_change)>

<cfoutput>
The original weight is #weight# grams<br>
The percent change is #NumberFormat(percent_change * 100, "99.9")#%<br>
The percent change reflects an increase, therefore the final weight is 
#NumberFormat(final_weight,"999.99")#<br><br>
</cfoutput>

<cfset percent_change = 154/1000>
<cfset final_weight = weight - (weight * percent_change)>

<cfoutput>
The original weight is #weight# grams<br>
The percent change is #NumberFormat(percent_change * 100, "99.9")#%<br>
The percent change reflects a decrease, therefore the final weight is 
#NumberFormat(final_weight,"999.99")#<br>
</cfoutput>

Dina

----- Original Message ----- 
  From: Tilbrook, Peter 
  To: CF-Talk 
  Sent: Thursday, October 18, 2001 8:02 PM
  Subject: Percent calculation


  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%): ??

  Thanks!

  PT


  **********************************************************************

  This transmission is intended only for the use of the addressee(s)
  and may contain confidential or legally privileged information. If you 
are
  not the intended recipient, you are notified that any use or 
dissemination
  of this communication is strictly prohibited. If you have received 
this
  transmission in error, please notify the ANZFA IT helpdesk prior to 
deleting
  all copies of this transmission together with any attachments.

  ANZFA helpdesk:

  E-mail:  [EMAIL PROTECTED]
  This footnote also confirms that this email message has been swept by
  MIMEsweeper for the presence of computer viruses.

  www.mimesweeper.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