[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

simon whale

3/27/2007 11:14:00 AM

hi all,

can anyone tell me how i would take a positive number x and make it a
negative number x. but when doing this i will not know the value of x.

any pointers would be grate full
Simon Whale


3 Answers

Roy Harvey

3/27/2007 11:33:00 AM

0

On Tue, 27 Mar 2007 12:14:03 +0100, "simon whale"
<simon@tiscali.co.uk> wrote:

>hi all,
>
>can anyone tell me how i would take a positive number x and make it a
>negative number x. but when doing this i will not know the value of x.
>
>any pointers would be grate full
>Simon Whale
>

Multiply by -1.

simon whale

3/27/2007 11:34:00 AM

0

worked a solution out

0 - x = -x

for example if x = 10

0 - 10 = -10

"simon whale" <simon@tiscali.co.uk> wrote in message
news:OyfRDFGcHHA.208@TK2MSFTNGP05.phx.gbl...
> hi all,
>
> can anyone tell me how i would take a positive number x and make it a
> negative number x. but when doing this i will not know the value of x.
>
> any pointers would be grate full
> Simon Whale
>


Raymond D'Anjou

3/27/2007 1:49:00 PM

0

Although both these solutions will convert a positive number to a negative,
they do have the side-effect of converting a negative number to a positive.

Try:
SET @x = -abs(@x)
or
SET @x = CASE WHEN @x < 0 THEN @x ELSE -@x END

"simon whale" <simon@tiscali.co.uk> wrote in message
news:%23rG9fOGcHHA.4684@TK2MSFTNGP06.phx.gbl...
> worked a solution out
>
> 0 - x = -x
>
> for example if x = 10
>
> 0 - 10 = -10
>
> "simon whale" <simon@tiscali.co.uk> wrote in message
> news:OyfRDFGcHHA.208@TK2MSFTNGP05.phx.gbl...
>> hi all,
>>
>> can anyone tell me how i would take a positive number x and make it a
>> negative number x. but when doing this i will not know the value of x.
>>
>> any pointers would be grate full
>> Simon Whale
>>
>
>