?
Solved

how do i disregard the sign of an integer when comparing ?

Posted on 2007-07-29
5
Medium Priority
?
254 Views
Last Modified: 2013-12-17
how do i disregard the sign of an integer when comparing ?  C#.
0
Comment
Question by:rigidigital
  • 3
4 Comments
 
LVL 33

Accepted Solution

by:
hongjun earned 2000 total points
ID: 19587945
You can try this

if (Math.Abs(number1) == Math.Abs(number2))
    //
0
 
LVL 33

Expert Comment

by:hongjun
ID: 19587946
Use the Math.Abs function.
This function will do a absolute and return you positive number.

hongjun
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 19588544
Depending on your data and what you  are doing, the standard mathematical way of doing this may be better ... compare the squares of the numbers.
0
 
LVL 33

Expert Comment

by:hongjun
ID: 19754976
http:#19587945 is good enough.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses
Course of the Month9 days, 23 hours left to enroll

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question