C examples for Operator:Arithmetic Operator
Also include float.h and display the values of FLT_DIG and DBL_DIG.
#include <stdio.h> #include <float.h> int main(void) { double db_one_third = 1.0 / 3.0; float ft_one_third = 1.0 / 3.0; printf("Float Double \n"); printf("-------------------- --------------------\n"); printf("%-20.4f %-20.4f\n", ft_one_third, db_one_third); // show 4 digits printf("%-20.12f %-20.12f\n", ft_one_third, db_one_third); // show 12 digits printf("%-20.16f %-20.16f\n", ft_one_third, db_one_third); printf("\n");//from w w w . j av a 2 s. co m printf("FLT_DIG: %d\n", FLT_DIG); printf("DBL_DIG: %d\n", DBL_DIG); /* both float and double are accurate to at least the amount of sig figs specified by FLT_DIG and DBL_DIG */ return 0; }