# Turning a negative number into a positive - Adobe Flash, Flex & Director

Hi, how can I turn a number such as -5 into +5 e.g. I have a variable: myVar = -5 how can I turn that into: myVar = +5 I'm sure there's an easy way to turn a negative into a positive Cheers ---------------------------------------------- [url]www.crazyrichie.net[/url]...

1. ## Turning a negative number into a positive

Hi, how can I turn a number such as -5 into +5

e.g. I have a variable:

myVar = -5

how can I turn that into:

myVar = +5

I'm sure there's an easy way to turn a negative into a positive

Cheers

----------------------------------------------

[url]www.crazyrichie.net[/url]

Richard Atkins Guest

2. ## Re: Turning a negative number into a positive

aVar = -5;
trace(aVar);
bVar = Math.abs(aVar);
trace(bVar);

hth

"Richard Atkins" <richatkins88yahoo.co.uk> wrote in message
news:c0ak3r\$6nh\$1forums.macromedia.com...
> Hi, how can I turn a number such as -5 into +5
>
> e.g. I have a variable:
>
> myVar = -5
>
> how can I turn that into:
>
> myVar = +5
>
> I'm sure there's an easy way to turn a negative into a positive
>
> Cheers
>
> ----------------------------------------------
>
> [url]www.crazyrichie.net[/url]
>
>
>

Jack Guest

3. ## Re: Turning a negative number into a positive

cheers jack,

I actually found if I do this it's even simpler:

myVar = -5

myVar = myVar*-1

myVar would then = +5

Rich

"Jack" <jackleamanhotmail.com> wrote in message
news:c0aktj\$7s8\$1forums.macromedia.com...
> aVar = -5;
> trace(aVar);
> bVar = Math.abs(aVar);
> trace(bVar);
>
> hth
>
> "Richard Atkins" <richatkins88yahoo.co.uk> wrote in message
> news:c0ak3r\$6nh\$1forums.macromedia.com...
> > Hi, how can I turn a number such as -5 into +5
> >
> > e.g. I have a variable:
> >
> > myVar = -5
> >
> > how can I turn that into:
> >
> > myVar = +5
> >
> > I'm sure there's an easy way to turn a negative into a positive
> >
> > Cheers
> >
> > ----------------------------------------------
> >
> > [url]www.crazyrichie.net[/url]
> >
> >
> >
>
>

Richard Atkins Guest

4. ## Re: Turning a negative number into a positive

"Richard Atkins" <richatkins88yahoo.co.uk> wrote in message
news:c0aujn\$nm6\$1forums.macromedia.com...
> cheers jack,
>
> I actually found if I do this it's even simpler:
>
> myVar = -5
>
> myVar = myVar*-1
>
> myVar would then = +5
>
> Rich
>
even simpler :-)
aVar = Math.abs(-5); trace(aVar);

Math.abs is a built-in Math function that computes
and returns an absolute value for the number specified

hth

Jack Guest

5. ## Re: Turning a negative number into a positive

nice one, cheers

"Jack" <jackleamanhotmail.com> wrote in message
news:c0b1g0\$s9e\$1forums.macromedia.com...
>
> "Richard Atkins" <richatkins88yahoo.co.uk> wrote in message
> news:c0aujn\$nm6\$1forums.macromedia.com...
> > cheers jack,
> >
> > I actually found if I do this it's even simpler:
> >
> > myVar = -5
> >
> > myVar = myVar*-1
> >
> > myVar would then = +5
> >
> > Rich
> >
>
> even simpler :-)
> aVar = Math.abs(-5); trace(aVar);
>
> Math.abs is a built-in Math function that computes
> and returns an absolute value for the number specified
>
> hth
>
>

Richard Atkins Guest

#### Posting Permissions

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