Re: Simple JS math?

2007-07-17 Thread Barney Boisvert
at'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? > &g

RE: Simple JS math?

2007-07-17 Thread Jim Davis
> -Original Message- > From: Barney Boisvert [mailto:[EMAIL PROTECTED] > Sent: Tuesday, July 17, 2007 11: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.

RE: Simple JS math?

2007-07-17 Thread Andy Matthews
Doing it that way you can't. One is a string, the other's a number. You'd have to first convert the fraction into it's decimal representation. You could prolly write a function to do that. Something like this would work: str = '3/8'; function convertDecimal(str) {

RE: Simple JS math?

2007-07-17 Thread Che Vilnonis
Thanks Barney... That did the trick. -Original Message- From: Barney Boisvert [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 17, 2007 11: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

RE: Simple JS math?

2007-07-17 Thread Andy Matthews
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 latt

Re: Simple JS math?

2007-07-17 Thread Ben Doom
It seems to me you have two choices. You can do it as a string (by converting the 20 to a string and adding a space and the fraction) or as a number, which will give you a decimal. Which are you trying to accomplish? --Ben Doom Che Vilnonis wrote: > Looking to add an integer and a fraction.

Re: Simple JS math?

2007-07-17 Thread Barney Boisvert
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: >

RE: Simple JS math?

2007-07-17 Thread Ben Nadel
Try: var num = 20.0; var frac = 3/8; var DBWTemp = (num + frac); document.write(DBWTemp); Should work. .. Ben Nadel Certified Advanced ColdFusion MX7 Developer www.bennadel.com Need ColdFusion Help? www.bennadel.com/ask-ben/ -Original Message- From: Che Vilnon

Re: Simple JS math?

2007-07-17 Thread Charlie Griefer
take 3/8 out of quotes. it's not a string. it's a number. you'll get 20.375. or were you looking for 20 3/8? 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! > > > var num = 20; > var frac = "3/8";