number 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/number.c +26 -14
- metadata +1 -1
data/ext/number.c
CHANGED
@@ -232,6 +232,16 @@ VALUE rb_Number_modulo (VALUE a, VALUE b)
|
|
232
232
|
return result;
|
233
233
|
}
|
234
234
|
|
235
|
+
VALUE rb_Number_eq_p (VALUE a, VALUE b)
|
236
|
+
{
|
237
|
+
return (CLASS_OF(b) == rb_cNumber || rb_obj_is_kind_of(b, rb_cNumeric)) && complex_re_n_eq_n_p(DATA_PTR(a), DATA_PTR(rb_convert_type(b, T_DATA, "Number", "to_number"))) ? Qtrue : Qfalse;
|
238
|
+
}
|
239
|
+
|
240
|
+
VALUE rb_Number_eqq_p (VALUE a, VALUE b)
|
241
|
+
{
|
242
|
+
return (CLASS_OF(b) == rb_cNumber || rb_obj_is_kind_of(b, rb_cNumeric)) && complex_eq_p(DATA_PTR(a), DATA_PTR(rb_convert_type(b, T_DATA, "Number", "to_number"))) ? Qtrue : Qfalse;
|
243
|
+
}
|
244
|
+
|
235
245
|
VALUE rb_Number_abs (VALUE number)
|
236
246
|
{
|
237
247
|
VALUE result = rb_obj_alloc(rb_cNumber);
|
@@ -586,9 +596,9 @@ VALUE rb_Number_real_right_unbounded_p (VALUE number)
|
|
586
596
|
return complex_re_right_unbounded_p(DATA_PTR(number)) ? Qtrue : Qfalse;
|
587
597
|
}
|
588
598
|
|
589
|
-
VALUE
|
599
|
+
VALUE rb_Number_real_enclose_p (VALUE a, VALUE b)
|
590
600
|
{
|
591
|
-
return
|
601
|
+
return complex_re_enclose_p(DATA_PTR(a), DATA_PTR(rb_convert_type(b, T_DATA, "Number", "to_number"))) ? Qtrue : Qfalse;
|
592
602
|
}
|
593
603
|
|
594
604
|
VALUE rb_Number_real_contain_l_p (VALUE a, VALUE b)
|
@@ -901,9 +911,9 @@ VALUE rb_Number_imag_right_unbounded_p (VALUE number)
|
|
901
911
|
return complex_im_right_unbounded_p(DATA_PTR(number)) ? Qtrue : Qfalse;
|
902
912
|
}
|
903
913
|
|
904
|
-
VALUE
|
914
|
+
VALUE rb_Number_imag_enclose_p (VALUE a, VALUE b)
|
905
915
|
{
|
906
|
-
return
|
916
|
+
return complex_im_enclose_p(DATA_PTR(a), DATA_PTR(rb_convert_type(b, T_DATA, "Number", "to_number"))) ? Qtrue : Qfalse;
|
907
917
|
}
|
908
918
|
|
909
919
|
VALUE rb_Number_imag_contain_l_p (VALUE a, VALUE b)
|
@@ -1196,9 +1206,9 @@ VALUE rb_Number_complex_unbounded_p (VALUE number)
|
|
1196
1206
|
return complex_unbounded_p(DATA_PTR(number)) ? Qtrue : Qfalse;
|
1197
1207
|
}
|
1198
1208
|
|
1199
|
-
VALUE
|
1209
|
+
VALUE rb_Number_complex_enclose_p (VALUE a, VALUE b)
|
1200
1210
|
{
|
1201
|
-
return
|
1211
|
+
return complex_enclose_p(DATA_PTR(a), DATA_PTR(rb_convert_type(b, T_DATA, "Number", "to_number"))) ? Qtrue : Qfalse;
|
1202
1212
|
}
|
1203
1213
|
|
1204
1214
|
VALUE rb_Number_complex_contain_ll_p (VALUE a, VALUE b)
|
@@ -1304,12 +1314,13 @@ void Init_number ()
|
|
1304
1314
|
rb_define_method(rb_cNumber, "/", rb_Number_divide, 1);
|
1305
1315
|
rb_define_method(rb_cNumber, "%", rb_Number_modulo, 1);
|
1306
1316
|
|
1317
|
+
rb_define_method(rb_cNumber, "==", rb_Number_eq_p, 1);
|
1318
|
+
rb_define_method(rb_cNumber, "===", rb_Number_eqq_p, 1);
|
1319
|
+
|
1307
1320
|
rb_define_method(rb_cNumber, "<", rb_Number_real_n_lt_n_p, 1);
|
1308
1321
|
rb_define_method(rb_cNumber, "<=", rb_Number_real_n_le_n_p, 1);
|
1309
1322
|
rb_define_method(rb_cNumber, ">", rb_Number_real_n_gt_n_p, 1);
|
1310
1323
|
rb_define_method(rb_cNumber, ">=", rb_Number_real_n_ge_n_p, 1);
|
1311
|
-
rb_define_method(rb_cNumber, "==", rb_Number_real_n_eq_n_p, 1);
|
1312
|
-
rb_define_method(rb_cNumber, "===", rb_Number_complex_eq_p, 1);
|
1313
1324
|
|
1314
1325
|
rb_define_method(rb_cNumber, "abs", rb_Number_abs, 0);
|
1315
1326
|
rb_define_method(rb_cNumber, "area", rb_Number_area, 0);
|
@@ -1318,10 +1329,10 @@ void Init_number ()
|
|
1318
1329
|
rb_define_method(rb_cNumber, "diagonal", rb_Number_diagonal, 0);
|
1319
1330
|
rb_define_method(rb_cNumber, "imag", rb_Number_imag, 0);
|
1320
1331
|
rb_define_method(rb_cNumber, "negate", rb_Number_negate, 0);
|
1321
|
-
rb_define_method(rb_cNumber, "reflect", rb_Number_reflect, 0);
|
1322
|
-
rb_define_method(rb_cNumber, "round", rb_Number_round, 0);
|
1323
1332
|
rb_define_method(rb_cNumber, "real", rb_Number_real, 0);
|
1324
1333
|
rb_define_method(rb_cNumber, "real?", rb_Number_real_p, 0);
|
1334
|
+
rb_define_method(rb_cNumber, "reflect", rb_Number_reflect, 0);
|
1335
|
+
rb_define_method(rb_cNumber, "round", rb_Number_round, 0);
|
1325
1336
|
rb_define_method(rb_cNumber, "sqrt", rb_Number_sqrt, 0);
|
1326
1337
|
|
1327
1338
|
rb_define_method(rb_cNumber, "ceil", rb_Number_round_c_c, 0);
|
@@ -1381,10 +1392,10 @@ void Init_number ()
|
|
1381
1392
|
rb_define_method(rb_cNumber, "imag_disjoint?", rb_Number_imag_disjoint_p, 1);
|
1382
1393
|
rb_define_method(rb_cNumber, "complex_disjoint?", rb_Number_complex_disjoint_p, 1);
|
1383
1394
|
|
1384
|
-
rb_define_method(rb_cNumber, "
|
1385
|
-
rb_define_method(rb_cNumber, "
|
1386
|
-
rb_define_method(rb_cNumber, "
|
1387
|
-
rb_define_method(rb_cNumber, "
|
1395
|
+
rb_define_method(rb_cNumber, "enclose?", rb_Number_real_enclose_p, 1);
|
1396
|
+
rb_define_method(rb_cNumber, "real_enclose?", rb_Number_real_enclose_p, 1);
|
1397
|
+
rb_define_method(rb_cNumber, "imag_enclose?", rb_Number_imag_enclose_p, 1);
|
1398
|
+
rb_define_method(rb_cNumber, "complex_enclose?", rb_Number_complex_enclose_p, 1);
|
1388
1399
|
|
1389
1400
|
rb_define_method(rb_cNumber, "contain_l?", rb_Number_real_contain_l_p, 1);
|
1390
1401
|
rb_define_method(rb_cNumber, "real_contain_l?", rb_Number_real_contain_l_p, 1);
|
@@ -1392,6 +1403,7 @@ void Init_number ()
|
|
1392
1403
|
rb_define_method(rb_cNumber, "complex_contain_ll?", rb_Number_complex_contain_ll_p, 1);
|
1393
1404
|
rb_define_method(rb_cNumber, "complex_contain_lu?", rb_Number_complex_contain_lu_p, 1);
|
1394
1405
|
|
1406
|
+
rb_define_method(rb_cNumber, "contain?", rb_Number_real_contain_n_p, 1);
|
1395
1407
|
rb_define_method(rb_cNumber, "contain_n?", rb_Number_real_contain_n_p, 1);
|
1396
1408
|
rb_define_method(rb_cNumber, "real_contain_n?", rb_Number_real_contain_n_p, 1);
|
1397
1409
|
rb_define_method(rb_cNumber, "imag_contain_n?", rb_Number_imag_contain_n_p, 1);
|