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; }
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; }
static void to_nearest() { set_rounding_mode(FE_TONEAREST); }
static void upward() { set_rounding_mode(FE_UPWARD); }
static void downward() { set_rounding_mode(FE_DOWNWARD); }
static void toward_zero() { set_rounding_mode(0x40000000); }
static void to_nearest() { set_rounding_mode(0x00000000); }
static void downward() { set_rounding_mode(rnd_mode.downward); }
void hwf_manager::set(hwf & o, mpf_rounding_mode rm, int n, int d) { set_rounding_mode(rm); o.value = ((double) n)/((double) d); }
static void toward_zero() { set_rounding_mode(FP_RZ); }
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; }
static void toward_zero() { set_rounding_mode(rnd_mode.toward_zero); }
static void upward() { set_rounding_mode(rnd_mode.upward); }
static void toward_zero() { set_rounding_mode(FE_TOWARDZERO); }
static void downward() { set_rounding_mode(0xc0000000); }
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); }
static void upward() { set_rounding_mode(0x80000000); }
static void toward_zero() { set_rounding_mode(mode_toward_zero.dmode); }
static void to_nearest() { set_rounding_mode(rnd_mode.to_nearest); }