Javascript Math Question-

1. Kentium Guest

## Javascript Math Question-

I need to take an integer, and convert it to a positive number regardless of whether it&#039;s postive or negative.<BR><BR>So say... -5 would be converted to +5<BR><BR>and at the same time<BR><BR>+5 remains +5<BR><BR>I&#039;d prefer to do it mathmatically, rather than using an IF statement.<BR><BR>Any ideas?<BR><BR>TIA!

2. Senior Member
Join Date
Dec 1969
Posts
2,885

## RE: Javascript Math Question-

abs(x)

3. Senior Member
Join Date
Dec 1969
Posts
11,334

## Absolute Value

look under math objects in the help manual.

4. Senior Member
Join Date
Dec 1969
Location
Los Angeles, CA
Posts
21,192

## Oh common

SOME research is all you EVER need.....but cant be bothered to huh<BR><BR><BR>try here<BR><BR>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/js56jslrfjscriptmethodstoc.asp

5. Kentium Guest

## great...thanks! (eom)

.

6. Senior Member
Join Date
Dec 1969
Posts
1,175

## "the" help manual?

Where is that?<BR><BR>I have never seen a JS "help" manual.<BR><BR>Just spotting documentation.

7. Senior Member
Join Date
Dec 1969
Location
Los Angeles, CA
Posts
21,192

## LOL....that will be the day <eop>

.

8. Senior Member
Join Date
Dec 1969
Posts
96,118

## That's VBScript...

In JavaScript, abs is a method on the built-in Math object, so you have to specify the object name:<BR><BR>var x = Math.abs(whatever);<BR><BR>But the other way:<BR><BR>x = ( whatever &#062; 0 ) ? whatever : - whatever;<BR><BR>

9. Senior Member
Join Date
Dec 1969
Posts
2,885

## RE: Javascript Math Question-

10. Senior Member
Join Date
Dec 1969
Location
Los Angeles, CA
Posts
21,192

## well isnt that the same thing

you go through the docs when you want help...<BR><BR><BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•