Class: GMP::Rnd
- Inherits:
-
Object
- Object
- GMP::Rnd
- Defined in:
- ext/gmp.c,
ext/mprnd.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
- #inspect ⇒ Object
Constructor Details
#initialize(*args) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'ext/mprnd.c', line 19
VALUE r_mprnd_initialize(int argc, VALUE *argv, VALUE self)
{
VALUE mode, name, ieee754;
const char *prefix;
char name_val[10];
mode = argv[0];
(void)argc;
if (MPFR_VERSION_MAJOR < 3)
prefix = "GMP";
else
prefix = "MPFR";
switch (FIX2INT (mode)) {
case 0:
sprintf (name_val, "%s_RNDN", prefix);
ieee754 = rb_str_new2 ("roundTiesToEven");
break;
case 1:
sprintf (name_val, "%s_RNDZ", prefix);
ieee754 = rb_str_new2 ("roundTowardZero");
break;
case 2:
sprintf (name_val, "%s_RNDU", prefix);
ieee754 = rb_str_new2 ("roundTowardPositive");
break;
case 3:
sprintf (name_val, "%s_RNDD", prefix);
ieee754 = rb_str_new2 ("roundTowardNegative");
break;
case 4:
sprintf (name_val, "%s_RNDA", prefix);
ieee754 = rb_str_new2 ("roundAwayFromZero");
break;
default:
sprintf (name_val, "%s_RNDN", prefix);
ieee754 = rb_str_new2 ("roundTiesToEven");
}
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
7 8 9 10 11 12 13 14 15 16 17 |
# File 'ext/mprnd.c', line 7
VALUE r_mprndsg_new(int argc, VALUE *argv, VALUE klass)
{
VALUE res;
int *res_value;
(void)klass;
res_value = 0;
mprnd_make_struct (res, res_value);
rb_obj_call_init (res, argc, argv);
return res;
}
|
Instance Method Details
#inspect ⇒ Object
62 63 64 65 |
# File 'ext/mprnd.c', line 62
VALUE r_mprnd_inspect(VALUE self)
{
return rb_iv_get (self, "@name");
}
|