Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,31 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
double inf = 1/0.0;
|
||||
double minus_inf = -1/0.0;
|
||||
double minus_zero = -1/ inf ;
|
||||
double nan = 0.0/0.0;
|
||||
|
||||
printf("positive infinity: %f\n",inf);
|
||||
printf("negative infinity: %f\n",minus_inf);
|
||||
printf("negative zero: %f\n",minus_zero);
|
||||
printf("not a number: %f\n",nan);
|
||||
|
||||
/* some arithmetic */
|
||||
|
||||
printf("+inf + 2.0 = %f\n",inf + 2.0);
|
||||
printf("+inf - 10.1 = %f\n",inf - 10.1);
|
||||
printf("+inf + -inf = %f\n",inf + minus_inf);
|
||||
printf("0.0 * +inf = %f\n",0.0 * inf);
|
||||
printf("1.0/-0.0 = %f\n",1.0/minus_zero);
|
||||
printf("NaN + 1.0 = %f\n",nan + 1.0);
|
||||
printf("NaN + NaN = %f\n",nan + nan);
|
||||
|
||||
/* some comparisons */
|
||||
|
||||
printf("NaN == NaN = %s\n",nan == nan ? "true" : "false");
|
||||
printf("0.0 == -0.0 = %s\n",0.0 == minus_zero ? "true" : "false");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
#include <stdio.h>
|
||||
#include <values.h>
|
||||
#include <math.h>
|
||||
|
||||
char * bits(double v) {
|
||||
static char s[sizeof(double) * (CHARBITS + 1)];
|
||||
int n, i, j;
|
||||
unsigned char *c = (void*)&v;
|
||||
for (i = n = 0; i < sizeof(double); i++) {
|
||||
for (j = 1 << (CHARBITS - 1); j; j >>= 1)
|
||||
s[n++] = (c[i] & j) ? '1' : '.';
|
||||
s[n++] = ' ';
|
||||
}
|
||||
s[n-1] = 0;
|
||||
return s;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
double x[] = {
|
||||
1.0, -1.0, 1.0/256, 0.0, // "normal" values
|
||||
-0.0, INFINITY, -INFINITY, NAN, -NAN, // special
|
||||
DBL_MAX, DBL_MIN // not required by task
|
||||
};
|
||||
int i;
|
||||
|
||||
for (i = 0; i < sizeof(x) / sizeof(x[0]); i++)
|
||||
printf("%s | %g\n", bits(x[i]), x[i]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue