#include #include typedef enum { NEAREST = 0, DOWN = 1, UP = 2, TRUNC = 3 } RoundingMode; void setRoundMode (RoundingMode mode) { uint16_t ctrl = 0; asm ("fstcw %0" : "=m"(ctrl)); ctrl = (ctrl & 0xF3ff) | (mode << 10); asm ("fldcw %0" : : "m"(ctrl)); } typedef enum { PREC_24 = 0, PREC_53 = 2, PREC_64 = 3 } Precision; void setPrecision (Precision pres) { uint16_t ctrl = 0; asm ("fstcw %0" : "=m"(ctrl)); ctrl = (ctrl & 0xFCFF) | (pres << 8); asm ("fldcw %0" : : "m"(ctrl)); } int main (void) { double alvo_s = 12345.6789; register double alvo_x = 1; int i; //setRoundMode (TRUNC); //setPrecision (PREC_53); for (i = 0; i < 100000000; ++i) alvo_x = (alvo_s * alvo_x) - (int) (alvo_s * alvo_x); printf ("%g\n", alvo_x); return 0; }