Một ví dụ khác
/* isfinite example */
#include <stdio.h> /* printf */
#include <math.h> /* isfinite, sqrt */
int main()
{
printf ("isfinite(0.0) : %d\n",isfinite
(0.0)); printf ("isfinite(1.0/0.0) : %d\n",isfinite
(1.0/0.0)); printf ("isfinite(-1.0/0.0) : %d\n",isfinite
(-1.0/0.0)); printf ("isfinite(sqrt(-1.0)): %d\n",isfinite
(sqrt(-1.0))); return 0;
}
http://www.cplusplus.com/reference/cmath/isfinite/
+ Biên dịch với Gcc (MinGw) không có vấn đề gì, Output:
Code:
isfinite(0.0) : 1
isfinite(1.0/0.0) : 0
isfinite(-1.0/0.0) : 0
isfinite(sqrt(-1.0)): 0
+ Biên dịch với Msc(vc2019 hại điện bậc nhất hiện nay) nó báo lỗi tréo ngoe:
error C2124: divide or mod by zero
ở dòng 8 và dòng 9 của code trên
+ Biên dịch với Bcc nó báo lỗi (dù có thay math.h bằng cmath)
error: use of undeclared identifier 'isfinite'
có nhìn thấy isfinite trong dinkumware64\cmath:198:
using _CSTD isfinite ; using _CSTD isinf ;
...
..
.