|
ms
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
negative int to positive int valueDoes anyone know if there is a easy way to change a negitive int value into a
positive int value. int a = -105 > change this to 105. With other words is there a command to change to neg sign into pos sign ? Bardo Versteeg (int)Math(Abs(<value>));
-- Show quoteBob Powell [MVP] Visual C#, System.Drawing Find great Windows Forms articles in Windows Forms Tips and Tricks http://www.bobpowell.net/tipstricks.htm Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/faqmain.htm All new articles provide code in C# and VB.NET. Subscribe to the RSS feeds provided and never miss a new article. "bardo" <ba***@discussions.microsoft.com> wrote in message news:8DF03CC6-5045-4ABC-893E-F78D256F2962@microsoft.com... > Does anyone know if there is a easy way to change a negitive int value > into a > positive int value. > > int a = -105 > change this to 105. > > With other words is there a command to change to neg sign into pos sign ? > > Bardo Versteeg If you mean to change it after a value has already been assigned to 'a':
Negative or Positive --> Positive a = Math.Abs(a) Reverse the sign a = -(a) or a = a * -1 Show quote "bardo" <ba***@discussions.microsoft.com> wrote in message news:8DF03CC6-5045-4ABC-893E-F78D256F2962@microsoft.com... > Does anyone know if there is a easy way to change a negitive int value > into a > positive int value. > > int a = -105 > change this to 105. > > With other words is there a command to change to neg sign into pos sign ? > > Bardo Versteeg bardo wrote:
> Does anyone know if there is a easy way to change a negitive int value into a a = a<0 ? -a : a; // if a is negative >>or<< positive> positive int value. > > int a = -105 > change this to 105. > > With other words is there a command to change to neg sign into pos sign ? Till
Other interesting topics
|
|||||||||||||||||||||||