number negative?

hi,

I have a little question: how can I check if a double variable represents a negative or a positive number.. I looked in the MSDN if there exists a function for that but I didn't find anything...:(

lg matti



Answer this question

number negative?

  • Greg Wojan

    You can always try comparing it to zero

    double d = 3.14;

    if (d > 0.0) {
    // ...
    }

    Or did I misunderstand your question



  • mike6271

    I beleive something like this can work:

    if ( d < 0.0 )
    {
    // d is negative
    }


  • number negative?