That's cool Barney. I didn't know it would be quite that efficient. Any
performance hits using eval? 

-----Original Message-----
From: Barney Boisvert [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, July 17, 2007 10:46 AM
To: CF-Talk
Subject: Re: Simple JS math?

num + eval(frac)

The latter operand will evaluate the string as if it were javascript (i.e.
do 3 / 8), which will give you the floating-point equivalent of the
fraction, which can then be added to the integer (giving 20.375).

cheers,
barneyb

On 7/17/07, Che Vilnonis <[EMAIL PROTECTED]> wrote:
> Looking to add an integer and a fraction. How do I do this with
Javascript?
> Thanks, Che!
>
> <script language="JavaScript">
> var num = 20;
> var frac = "3/8";
> var DBWTemp = (num + frac);
> document.write(DBWTemp);
> </script>
>
>
>
> 



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
ColdFusion MX7 by AdobeĀ®
Dyncamically transform webcontent into Adobe PDF with new ColdFusion MX7. 
Free Trial. http://www.adobe.com/products/coldfusion?sdid=RVJV

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

Reply via email to