Programming language is C write a function which will return the following value
ID: 3602593 • Letter: P
Question
Programming language is C
write a function which will return the following values using only integer constants 0-255, locally declared integers, unary integer operations, and binary integer operations.
*a negative integer, if the floating-point number is a “special” (±, or NaN).
*zero, if the floating-point number is denormalized.
*a positive integer, if the floating-point number is normalized.
the function takes a single parameter 'f' of type float_bits which is defined as
typedef unsigned float_bits
Explanation / Answer
#include<stdio.h>
int main()
{
int i;
for(i=0;i<=255;i++)
{
printf("ASCII VALUE OF CHARACTER%c=%d/n",i,i);
}
return 0;
}
#include <math.h>
#include <stdio.h>
int main(int argc,char**argv){
double ninf=-INFINITY;
double pinf=INFINITY;
printf("1/inf = %lf ",1/pinf);
printf("1/-inf = %lf (negative zero) ",1/ninf);
printf("2*inf = %lf ",2.0*pinf);
printf("2 > inf = %s ",2>pinf?"yes":"no");
printf("2 > -inf = %s ",2>ninf?"yes":"no");
printf("inf - inf = %lf (sign of NaN has no real meaning) ",pinf-pinf);
printf("0 * inf = %lf (sign of NaN has no real meaning) ",0.0*pinf);
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.