Since C++11, additional overloads are provided in this header (<cmath>) for the integral types: These overloads effectively cast x to a double before calculations (defined for T being any integral type).
Your result might be so close to 1.0 that it always ends up printing as 1, but any difference at all (which is entirely possible when doing any floating point operation, even on cast integers) means that the result might fail an == 1 test.
Try your own integer only abs() function - it's dead easy to write one.