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

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -