??????些?????????????????????e??????????????std::abs???????????????????????????????????????小?????int???????????????????????纾�

int min_int = -2147483648;
cout<

????????????????-2147483648????????????锌????????????????????????????????????

????1????????姹�??

unsigned int __abs(int value)
{
    return (value >= 0) ? value : -value;
}

?????????std::abs????路?????????

????2????????姹�??

#include

unsigned int __abs(int value)
{
    return (std::numeric_limits::min() == value || value >= 0) ? value : -value;
}

????????姹�?????????????????std::numeric_limits::min()??????????int???小???????????int???????????????????value??小??int???????value????????????????????位??位?????——???unsigned int??蟹???位????????????械????value???小?????????????????????伞?

??????????姹�???????????????卸????????????????????????????

????3?????????姹�??

unsigned int __abs(int value)
{
    unsigned int copyed_value = value;
    return (copyed_value > 0x80000000) ? -value : copyed_value;
}

???????32位??小??int??0x80000000——??位????位?1????位??位??????unsigned int????????????????????????????????位?1??????位????????????-1??16?????????0x80000001????????????????位??位?????????copyed_value?小???????????卸??????

??????1?????copyed_value?????0x80000000??????value?????????????????????????-value????

??????2?????copyed_value?????0x80000000??????value?????小??????????????位??位??????copyed_value?写?????value????????????copyed_value??

??????3?????copyed_value??小??0x80000000?????value???????????alue????copyed_value???伞?

????????????????????2?????3??????????????copyed_value??????????????????????????伪???????????????????巍??????????????????????????????????谩?

????????????????????????????????????????????????????????????????小int?????????????std::abs????????????????????????????????????????????????????????????????小int?????????????????????????????????????????

??????????????????????????????????????娌�??????????????????校???????????????????煤?????