c++ - Fixed point implementation of int min -
i reading positive , negative infinity in c++ , trying implement them in fixed point math arthimethic implementation
i can see max of int equal std::numeric_limits<int>::max(); in c++
and min value of int equal std::numeric_limits<int>::min(); in c++
here defining int max , int min manually in fixed point math implemenation, doubt int min = -int max; or int min = -int max -1; ?
can clear it?
it depends on sign representation, assume two's complement.
in case, have -x = ~x + 1 x + (~x) = -1 every signed integer x.
so int min = (~max) + -1 = - ( (unsigned int) max) + -1
Comments
Post a Comment