?
This document uses PHP Chinese website manual Release
在頭文件<stdlib.h>中定義 | ||
---|---|---|
#define INFINITY /*implementation defined*/ | (since C99) |
如果實(shí)現(xiàn)支持浮點(diǎn)無窮大,則宏INFINITY
將擴(kuò)展為float
求值為正或無符號(hào)無窮大的類型的常量表達(dá)式。
如果實(shí)現(xiàn)不支持浮點(diǎn)無窮大,宏INFINITY
將擴(kuò)展為一個(gè)肯定的值,保證float
在編譯時(shí)溢出,并且使用此宏會(huì)生成編譯器警告。
用于打印無窮大的樣式是實(shí)現(xiàn)定義的。
顯示樣式用于打印無限和IEEE格式。
#include <stdio.h>#include <math.h>#include <stdint.h>#include <inttypes.h>#include <string.h> int main(void){ double f = INFINITY; uint64_t fn; memcpy(&fn, &f, sizeof f); printf("INFINITY: %f %" PRIx64 "\n", f, fn);}
可能的輸出:
INFINITY: inf 7ff0000000000000
C11標(biāo)準(zhǔn)(ISO / IEC 9899:2011):
7.12 / 4 INFINITY(p:231-232)
C99標(biāo)準(zhǔn)(ISO / IEC 9899:1999):
7.12 / 4 INFINITY(p:212-213)