Why isn't `int pow(int base, int exponent)` in the standard C++ libraries?

前端 未结 11 1367
礼貌的吻别
礼貌的吻别 2020-11-27 02:20

I feel like I must just be unable to find it. Is there any reason that the C++ pow function does not implement the \"power\" function for anything except

11条回答
  •  青春惊慌失措
    2020-11-27 03:06

    One reason for C++ to not have additional overloads is to be compatible with C.

    C++98 has functions like double pow(double, int), but these have been removed in C++11 with the argument that C99 didn't include them.

    http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3286.html#550

    Getting a slightly more accurate result also means getting a slightly different result.

提交回复
热议问题