예제 #1
0
int FCSRRoundingMode(flt_round_op_t op1)
{
   double fd_d = 0;
   float fd_f = 0;
   int fd_w = 0;
   int i;
   int fcsr = 0;
   round_mode_t rm;
   for (rm = TO_NEAREST; rm <= TO_MINUS_INFINITY; rm ++) {
      set_rounding_mode(rm);
      printf("roundig mode: %s\n", round_mode_name[rm]);
      for (i = 0; i < 24; i++) {
         set_rounding_mode(rm);
         switch(op1) {
            case CVTDS:
                 UNOPfd("cvt.d.s");
                 printf("%s %lf %lf\n", flt_round_op_names[op1], fd_d, fs_f[i]);
                 printf("fcsr: 0x%x\n", fcsr);
                 break;
            case CVTDW:
                 UNOPwd("cvt.d.w");
                 printf("%s %lf %d\n", flt_round_op_names[op1], fd_d, fs_w[i]);
                 printf("fcsr: 0x%x\n", fcsr);
                 break;
            case CVTSD:
                 UNOPdf("cvt.s.d");
                 printf("%s %f %lf\n", flt_round_op_names[op1], fd_f, fs_d[i]);
                 printf("fcsr: 0x%x\n", fcsr);
                 break;
            case CVTSW:
                 UNOPwf("cvt.s.w");
                 printf("%s %f %d\n", flt_round_op_names[op1], fd_f, fs_w[i]);
                 printf("fcsr: 0x%x\n", fcsr);
                 break;
            case CVTWS:
                 UNOPfw("cvt.w.s");
                 printf("%s %d %f\n", flt_round_op_names[op1], fd_w, fs_f[i]);
                 printf("fcsr: 0x%x\n", fcsr);
                 break;
            case CVTWD:
                 UNOPdw("cvt.w.d");
                 printf("%s %d %lf\n", flt_round_op_names[op1], fd_w, fs_d[i]);
                 printf("fcsr: 0x%x\n", fcsr);
                 break;
            default:
                 printf("error\n");
                 break;
         }
      }
   }
   return 0;
}
예제 #2
0
int directedRoundingMode(flt_dir_op_t op) {
   int fd_w = 0;
   int i;
   int fcsr = 0;
   round_mode_t rm = TO_NEAREST;
   for (i = 0; i < 24; i++) {
      set_rounding_mode(rm);
      switch(op) {
         case CEILWS:
              UNOPfw("ceil.w.s");
              printf("%s %d %f\n", flt_dir_op_names[op], fd_w, fs_f[i]);
              printf("fcsr: 0x%x\n", fcsr);
              break;
         case CEILWD:
              UNOPdw("ceil.w.d");
              printf("%s %d %lf\n", flt_dir_op_names[op], fd_w, fs_d[i]);
              printf("fcsr: 0x%x\n", fcsr);
              break;
         case FLOORWS:
              UNOPfw("floor.w.s");
              printf("%s %d %f\n", flt_dir_op_names[op], fd_w, fs_f[i]);
              printf("fcsr: 0x%x\n", fcsr);
              break;
         case FLOORWD:
              UNOPdw("floor.w.d");
              printf("%s %d %lf\n", flt_dir_op_names[op], fd_w, fs_d[i]);
              printf("fcsr: 0x%x\n", fcsr);
              break;
         case ROUNDWS:
              UNOPfw("round.w.s");
              printf("%s %d %f\n", flt_dir_op_names[op], fd_w, fs_f[i]);
              printf("fcsr: 0x%x\n", fcsr);
              break;
         case ROUNDWD:
              UNOPdw("round.w.d");
              printf("%s %d %lf\n", flt_dir_op_names[op], fd_w, fs_d[i]);
              printf("fcsr: 0x%x\n", fcsr);
              break;
         case TRUNCWS:
              UNOPfw("trunc.w.s");
              printf("%s %d %f\n", flt_dir_op_names[op], fd_w, fs_f[i]);
              printf("fcsr: 0x%x\n", fcsr);
              break;
         case TRUNCWD:
              UNOPdw("trunc.w.d");
              printf("%s %d %lf\n", flt_dir_op_names[op], fd_w, fs_d[i]);
              printf("fcsr: 0x%x\n", fcsr);
              break;
        default:
            printf("error\n");
            break;
        }
    }
   return 0;
}
예제 #3
0
 static void to_nearest()  {
     set_rounding_mode(FE_TONEAREST);
 }
예제 #4
0
 static void upward()      {
     set_rounding_mode(FE_UPWARD);
 }
예제 #5
0
 static void downward()    {
     set_rounding_mode(FE_DOWNWARD);
 }
예제 #6
0
 static void toward_zero() { set_rounding_mode(0x40000000); }
예제 #7
0
 static void to_nearest()  { set_rounding_mode(0x00000000); }
예제 #8
0
 static void downward()    { set_rounding_mode(rnd_mode.downward);    }
예제 #9
0
void hwf_manager::set(hwf & o, mpf_rounding_mode rm, int n, int d) {
    set_rounding_mode(rm);
    o.value = ((double) n)/((double) d);
}
예제 #10
0
 static void toward_zero() { set_rounding_mode(FP_RZ); }
예제 #11
0
int arithmeticOperations(flt_art_op_t op)
{
   double fd_d = 0;
   float fd_f = 0;
   int i = 0;
   round_mode_t rm;
   for (rm = TO_NEAREST; rm <= TO_MINUS_INFINITY; rm ++) {
      set_rounding_mode(rm);
      printf("rounding mode: %s\n", round_mode_name[rm]);
      for (i = 0; i < 24; i++)
      {
         switch(op) {
            case ABSS:
                 UNOPff("abs.s");
                 printf("%s %f %f\n", flt_art_op_names[op], fd_f, fs_f[i]);
                 break;
            case ABSD:
                 UNOPdd("abs.d");
                 printf("%s %lf %lf\n", flt_art_op_names[op], fd_d, fs_d[i]);
                 break;
            case ADDS:
                 BINOPf("add.s");
                 printf("%s %f %f %f\n", flt_art_op_names[op], fd_f, fs_f[i], ft_f[i]);
                 break;
            case ADDD:
                 BINOPd("add.d");
                 printf("%s %lf %lf %lf\n", flt_art_op_names[op], fd_d, fs_d[i], ft_d[i]);
                 break;
            case DIVS:
                 BINOPf("div.s");
                 printf("%s %f %f %f\n", flt_art_op_names[op], fd_f, fs_f[i], ft_f[i]);
                 break;
            case DIVD:
                 BINOPd("div.d");
                 printf("%s %lf %lf %lf\n", flt_art_op_names[op], fd_d, fs_d[i], ft_d[i]);
                 break;
            case MULS:
                 BINOPf("mul.s");
                 printf("%s %f %f %f\n", flt_art_op_names[op], fd_f, fs_f[i], ft_f[i]);
                 break;
            case MULD:
                 BINOPd("mul.d");
                 printf("%s %lf %lf %lf\n", flt_art_op_names[op], fd_d, fs_d[i], ft_d[i]);
                 break;
            case NEGS:
                 UNOPff("neg.s");
                 printf("%s %f %f\n", flt_art_op_names[op], fd_f, fs_f[i]);
                 break;
            case NEGD:
                 UNOPdd("neg.d");
                 printf("%s %lf %lf\n", flt_art_op_names[op], fd_d, fs_d[i]);
                 break;
            case SQRTS:
                 UNOPff("sqrt.s");
                 printf("%s %f %f\n", flt_art_op_names[op], fd_f, fs_f[i]);
                 break;
            case SQRTD:
                 UNOPdd("sqrt.d");
                 printf("%s %lf %lf\n", flt_art_op_names[op], fd_d, fs_d[i]);
                 break;
            case SUBS:
                 BINOPf("sub.s");
                 printf("%s %f %f %f\n", flt_art_op_names[op], fd_f, fs_f[i], ft_f[i]);
                 break;
            case SUBD:
                 BINOPd("sub.d");
                 printf("%s %lf %lf %lf\n", flt_art_op_names[op], fd_d, fs_d[i], ft_d[i]);
                 break;
            case RECIPS:
#if (__mips==32) && (__mips_isa_rev>=2)
                 UNOPff("recip.s");
                 printf("%s %f %f\n", flt_art_op_names[op], fd_f, fs_f[i]);
#endif
                 break;
            case RECIPD:
#if (__mips==32) && (__mips_isa_rev>=2)
                 UNOPdd("recip.d");
                 printf("%s %lf %lf\n", flt_art_op_names[op], fd_d, fs_d[i]);
#endif
                 break;
            case RSQRTS:
#if (__mips==32) && (__mips_isa_rev>=2)
                 UNOPff("rsqrt.s");
                 printf("%s %f %f\n", flt_art_op_names[op], fd_f, fs_f[i]);
#endif
                 break;
            case RSQRTD:
#if (__mips==32) && (__mips_isa_rev>=2)
                 UNOPdd("rsqrt.d");
                 printf("%s %lf %lf\n", flt_art_op_names[op], fd_d, fs_d[i]);
#endif
                 break;
            default:
               printf("error\n");
               break;
         }
      }
   }
   return 0;
}
예제 #12
0
 static void toward_zero() { set_rounding_mode(rnd_mode.toward_zero); }
예제 #13
0
 static void upward()      { set_rounding_mode(rnd_mode.upward);      }
예제 #14
0
 static void toward_zero() {
     set_rounding_mode(FE_TOWARDZERO);
 }
예제 #15
0
 static void downward()    { set_rounding_mode(0xc0000000); }
예제 #16
0
void hwf_manager::set(hwf & o, mpf_rounding_mode rm, mpq const & value) {
    set_rounding_mode(rm);
    o.value = m_mpq_manager.get_double(value);
}
예제 #17
0
 static void upward()      { set_rounding_mode(0x80000000); }
예제 #18
0
 static void toward_zero() { set_rounding_mode(mode_toward_zero.dmode); }
예제 #19
0
 static void to_nearest()  { set_rounding_mode(rnd_mode.to_nearest);  }