Add 50 cents then truncate, or just use the Round() CF function.

<cfset retail = 82>
<cfset discount_rate = 0.0525>
<cfset final_price = Int(retail * (1 - discount_rate) + 0.50)>

or

<cfset final_price = Round(retail * (1 - discount_rate)>

----- Original Message -----
From: "Jordan Michaels" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Thursday, October 14, 2004 2:36 PM
Subject: Rounding up dollar figures

> How can I make NumberFormat() round UP instead of down? For example:
>
> NumberFormat(Evaluate(RETAIL1-(RETAIL1 * DiscountRate)),
> "999,999,999.00")
>
> So, say we plug some numbers in there:
>
> Retail Value: $82 dollars
> Discount Rate: 5.25% off
>
> NumberFormat(Evaluate(82-(82 * 0.0525)), "999,999,999.00")
>
> The actual result of 82-(82 * 0.0525) is 77.695, so I need that number
> to round up to 77.70. Instead, using the NumberFormat function results
> in a value of 77.69. How can I make this round up correctly!?
>
> Thanks in advance for any help anyone can offer!
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to