Change the sign of an integer

  • Thread starter Thread starter Totto
  • Start date Start date
Hi,
How do I change a positiv integer to a negative value ?
tnx
Totto

Dim value As Integer = Math.Abs(MyInt) * -1

value will always be negative...
 
Totto,
In addition to multiple by -1 as Tom showed, you can subtract from 0.

Dim value As Integer = 0 - Math.Abs(MyInt)

I'm sure there are one or two other methods you could use.

Hope this helps
Jay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top