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

Posted on 2007-07-29
Last Modified: 2013-12-17
how do i disregard the sign of an integer when comparing ?  C#.
Question by:rigidigital
    LVL 33

    Accepted Solution

    You can try this

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

    Expert Comment

    Use the Math.Abs function.
    This function will do a absolute and return you positive number.

    LVL 37

    Expert Comment

    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.
    LVL 33

    Expert Comment

    http:#19587945 is good enough.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
    In my previous two articles we discussed Binary Serialization ( and XML Serialization ( In this article we will try to know more about SOAP (Simple Object Acces…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    734 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

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now