Hey Ken,
Theres not really a nice way to do this actually.Heres a prototype... it
should do the trick.
Number.prototype.addCents = function() {
var a = ((Math.round(this*100)/100)+"").split(".");
a[1] = (a[1]+"00").substr(0, 2);
return a.join(".");
};
// Usage
var price = 123.4;
var discount = 56.8;
price = price - discount;// 66.6
total = price.addCents();// 66.60
Sincerely,
Kevin
-----Original Message-----
From: Ken Ferguson [mailto:[EMAIL PROTECTED]
Sent: Monday, June 06, 2005 2:36 PM
To: CF-Talk
Subject: Actionscript equiv to decimalFormat()
Is there one? I know that all numbers in AS are floating point numbers,
but I'm returning a value from a function like this:
(simplified code...)
y = Number(itemValue) * Number(quantity);
subTotalValue.text = y;
When the value is something like 29, I'd like it to show as 29.00
instead. It's very clear though, that this is not happening. My text box
shows 29 instead.
I'm sure that this is simple and one of you AS experts out there will
most likely read this and wonder how I can even figure out how to manage
breathing, but I am not an AS expert, so please don't hold it against me!
Thanks,
Ferg
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking
application. Start tracking and documenting hours spent on a project or with a
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:208737
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54