Class: MPC::Rnd
- Inherits:
-
Object
- Object
- MPC::Rnd
- Defined in:
- ext/mpcrnd.c
Instance Attribute Summary collapse
- #ieee754 ⇒ Object readonly
- #mode ⇒ Object readonly
- #name ⇒ Object readonly
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*args) ⇒ Object
constructor
MPC_RNDNN 0000 0000 MPC_RNDNZ 0001 0000 MPC_RNDNU 0010 0000 MPC_RNDND 0011 0000 MPC_RNDNA ---- ---- MPC_RNDZN 0000 0001 MPC_RNDZZ 0001 0001 MPC_RNDZU 0010 0001 MPC_RNDZD 0011 0001 MPC_RNDZA ---- ---- MPC_RNDUN 0000 0010 MPC_RNDUZ 0001 0010 MPC_RNDUU 0010 0010 MPC_RNDUD 0011 0010 MPC_RNDUA ---- ---- MPC_RNDDN 0000 0011 MPC_RNDDZ 0001 0011 MPC_RNDDU 0010 0011 MPC_RNDDD 0011 0011 MPC_RNDDA ---- ---- MPC_RNDAN ---- ---- MPC_RNDAZ ---- ---- MPC_RNDAU ---- ---- MPC_RNDAD ---- ---- MPC_RNDAA ---- ----.
- #inspect ⇒ Object
Constructor Details
#initialize(*args) ⇒ Object
MPC_RNDNN 0000 0000 MPC_RNDNZ 0001 0000 MPC_RNDNU 0010 0000 MPC_RNDND 0011 0000 MPC_RNDNA ---- ---- MPC_RNDZN 0000 0001 MPC_RNDZZ 0001 0001 MPC_RNDZU 0010 0001 MPC_RNDZD 0011 0001 MPC_RNDZA ---- ---- MPC_RNDUN 0000 0010 MPC_RNDUZ 0001 0010 MPC_RNDUU 0010 0010 MPC_RNDUD 0011 0010 MPC_RNDUA ---- ---- MPC_RNDDN 0000 0011 MPC_RNDDZ 0001 0011 MPC_RNDDU 0010 0011 MPC_RNDDD 0011 0011 MPC_RNDDA ---- ---- MPC_RNDAN ---- ---- MPC_RNDAZ ---- ---- MPC_RNDAU ---- ---- MPC_RNDAD ---- ---- MPC_RNDAA ---- ----
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'ext/mpcrnd.c', line 44
VALUE r_mpcrnd_initialize(int argc, VALUE *argv, VALUE self)
{
VALUE mode, name, ieee754;
char name_val[12];
(void)argc;
mode = argv[0];
switch (FIX2INT(mode) % 16) {
case 0:
sprintf(name_val, "MPC_RNDN");
ieee754 = rb_str_new2("(roundTiesToEven,");
break;
case 1:
sprintf(name_val, "MPC_RNDZ");
ieee754 = rb_str_new2("(roundTowardZero,");
break;
case 2:
sprintf(name_val, "MPC_RNDU");
ieee754 = rb_str_new2("(roundTowardPositive,");
break;
case 3:
sprintf(name_val, "MPC_RNDD");
ieee754 = rb_str_new2("(roundTowardNegative,");
break;
default:
sprintf(name_val, "MPC_RNDN");
ieee754 = rb_str_new2("(roundTiesToEven,");
}
switch (FIX2INT(mode) >> 4) {
case 0:
sprintf(name_val, "%sN", name_val);
rb_str_cat(ieee754, "roundTiesToEven)", 16);
break;
case 1:
sprintf(name_val, "%sZ", name_val);
rb_str_cat(ieee754, "roundTowardZero)", 16);
break;
case 2:
sprintf(name_val, "%sU", name_val);
rb_str_cat(ieee754, "roundTowardPositive)", 20);
break;
case 3:
sprintf(name_val, "%sD", name_val);
rb_str_cat(ieee754, "roundTowardNegative)", 20);
break;
default:
sprintf(name_val, "%sN", name_val);
rb_str_cat(ieee754, "roundTiesToEven)", 16);
}
name = rb_str_new2(name_val);
rb_iv_set (self, "@mode", mode);
rb_iv_set (self, "@name", name);
rb_iv_set (self, "@ieee754", ieee754);
return Qnil;
}
|
Instance Attribute Details
#ieee754 ⇒ Object (readonly)
#mode ⇒ Object (readonly)
#name ⇒ Object (readonly)
Class Method Details
.new(*args) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'ext/mpcrnd.c', line 5
VALUE r_mpcrndsg_new(int argc, VALUE *argv, VALUE klass)
{
VALUE res;
int *res_value;
(void)klass;
res_value = 0;
mpcrnd_make_struct(res, res_value);
rb_obj_call_init(res, argc, argv);
return res;
}
|
Instance Method Details
#inspect ⇒ Object
102 103 104 105 |
# File 'ext/mpcrnd.c', line 102
VALUE r_mpcrnd_inspect(VALUE self)
{
return rb_iv_get (self, "@name");
}
|