How do you check for infinite and indeterminate values in C++?

前端 未结 6 2086
借酒劲吻你
借酒劲吻你 2020-12-29 20:31

In my programs infinity usually arises when a value is divided by zero. I get indeterminate when I divide zero by zero. How do you check for infinite and indeterminate value

6条回答
  •  执笔经年
    2020-12-29 21:07

    For Visual Studio I would use _isnan and _finite, or perhaps _fpclass.

    But if you have access to a C++11-able standard library and compiler you could use std::isnan and std::isinf.

提交回复
热议问题