Is fpclassify(x) == FP_NAN functionally equivalent to isnan(x)?
The same question goes for:
fpclassify(x) == FP_INFINITEvs.isinf(x)fpclassify(x) == FP_NORMALvs.isnormal(x)fpclassify(x) == FP_SUBNORMALvs.issubnormal(x)fpclassify(x) == FP_ZEROvs.iszero(x)
If they are functionally equivalent, then why need of duplicates?
They're functionally equivalent. But
fpclassifyallows you to perform a single test and use aswitchstatement, which may be slightly faster and/or produce simpler code than the chainedif/else if/elseblocks would use to perform type by type checks (assumingfpclassifyitself has efficient ways to differentiate itself; won't swear to that), e.g. per the cppreference example: