1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
/* llrint example */
#include <stdio.h> /* printf */
#include <fenv.h> /* fegetround, FE_* */
#include <math.h> /* llrint */
int main ()
{
printf ("rounding using ");
switch (fegetround()) {
case FE_DOWNWARD: printf ("downward"); break;
case FE_TONEAREST: printf ("to-nearest"); break;
case FE_TOWARDZERO: printf ("toward-zero"); break;
case FE_UPWARD: printf ("upward"); break;
default: printf ("unknown");
}
printf (" rounding:\n");
printf ( "llrint (2.3) = %lld\n", llrint(2.3) );
printf ( "llrint (3.8) = %lld\n", llrint(3.8) );
printf ( "llrint (-2.3) = %lld\n", llrint(-2.3) );
printf ( "llrint (-3.8) = %lld\n", llrint(-3.8) );
return 0;
}
|