summaryrefslogtreecommitdiff
path: root/ext/bigdecimal
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-06-18 02:25:28 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-06-18 02:25:28 (GMT)
commitc79c06fa1c3844225cd46ba5b41d8afe6fa27ab4 (patch)
tree928f6db35566d0d9b3926d983a8d159d4641357b /ext/bigdecimal
parent5065e28809930d7a7941abf94c8ded2728196141 (diff)
Integer conversion
* ext/bigdecimal/bigdecimal.c: use NUM2INT and NUM2USHORT to reject nil. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55438 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/bigdecimal')
-rw-r--r--ext/bigdecimal/bigdecimal.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index ebd452e..b1c887c 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -468,7 +468,7 @@ check_rounding_mode(VALUE const v)
break;
}
- sw = (unsigned short)FIX2UINT(v);
+ sw = NUM2USHORT(v);
if (!VpIsRoundMode(sw)) {
rb_raise(rb_eArgError, "invalid rounding mode");
}
@@ -521,7 +521,7 @@ BigDecimal_mode(int argc, VALUE *argv, VALUE self)
unsigned long f,fo;
rb_scan_args(argc, argv, "11", &which, &val);
- f = (unsigned long)FIX2INT(which);
+ f = (unsigned long)NUM2INT(which);
if (f & VP_EXCEPTION_ALL) {
/* Exception mode setting */
@@ -591,7 +591,7 @@ static SIGNED_VALUE
GetPositiveInt(VALUE v)
{
SIGNED_VALUE n;
- n = FIX2INT(v);
+ n = NUM2INT(v);
if (n < 0) {
rb_raise(rb_eArgError, "argument must be positive");
}
@@ -1720,10 +1720,10 @@ BigDecimal_round(int argc, VALUE *argv, VALUE self)
iLoc = 0;
break;
case 1:
- iLoc = FIX2INT(vLoc);
+ iLoc = NUM2INT(vLoc);
break;
case 2:
- iLoc = FIX2INT(vLoc);
+ iLoc = NUM2INT(vLoc);
sw = check_rounding_mode(vRound);
break;
default:
@@ -1774,7 +1774,7 @@ BigDecimal_truncate(int argc, VALUE *argv, VALUE self)
iLoc = 0;
}
else {
- iLoc = FIX2INT(vLoc);
+ iLoc = NUM2INT(vLoc);
}
GUARD_OBJ(a, GetVpValue(self, 1));
@@ -1834,7 +1834,7 @@ BigDecimal_floor(int argc, VALUE *argv, VALUE self)
iLoc = 0;
}
else {
- iLoc = FIX2INT(vLoc);
+ iLoc = NUM2INT(vLoc);
}
GUARD_OBJ(a, GetVpValue(self, 1));
@@ -1880,7 +1880,7 @@ BigDecimal_ceil(int argc, VALUE *argv, VALUE self)
if (rb_scan_args(argc, argv, "01", &vLoc) == 0) {
iLoc = 0;
} else {
- iLoc = FIX2INT(vLoc);
+ iLoc = NUM2INT(vLoc);
}
GUARD_OBJ(a, GetVpValue(self, 1));
@@ -2623,7 +2623,7 @@ BigDecimal_limit(int argc, VALUE *argv, VALUE self)
if (rb_scan_args(argc, argv, "01", &nFig) == 1) {
int nf;
if (NIL_P(nFig)) return nCur;
- nf = FIX2INT(nFig);
+ nf = NUM2INT(nFig);
if (nf < 0) {
rb_raise(rb_eArgError, "argument must be positive");
}
@@ -3458,7 +3458,7 @@ VpGetException (void)
return RMPD_EXCEPTION_MODE_DEFAULT;
}
- return (unsigned short)FIX2UINT(vmode);
+ return NUM2USHORT(vmode);
}
static void
@@ -3528,7 +3528,7 @@ VpGetRoundMode(void)
return RMPD_ROUNDING_MODE_DEFAULT;
}
- return (unsigned short)FIX2INT(vmode);
+ return NUM2USHORT(vmode);
}
VP_EXPORT int