Preprocessor Solution

  • + 3 comments

    According to me there are several things wrong in this logic. First of all, !(NOT) is a LOGICAL operator.. not a binary one. NOT of any non zero argument will return 0 and the NOT of 0 ie !0 = 1

    Secondly, the problem with unsigned is that the code includes a -INF hence your INF should only be set to the highest number possible in signed int. According to me this will be the best

    #define INF (1<<31)-1
    

    which is equal to 2147483647