@@ -11,7 +11,7 @@ void sympify(VALUE operand2, basic_struct *cbasic_operand2) {
1111 switch (TYPE (operand2 )) {
1212 case T_FIXNUM :
1313 case T_BIGNUM :
14- GET_SYMINTFROMVAL (operand2 , cbasic_operand2 );
14+ get_symintfromval (operand2 , cbasic_operand2 );
1515 break ;
1616
1717 case T_FLOAT :
@@ -27,8 +27,8 @@ void sympify(VALUE operand2, basic_struct *cbasic_operand2) {
2727 basic_new_stack (num_basic );
2828 basic_new_stack (den_basic );
2929
30- GET_SYMINTFROMVAL (num , num_basic );
31- GET_SYMINTFROMVAL (den , den_basic );
30+ get_symintfromval (num , num_basic );
31+ get_symintfromval (den , den_basic );
3232
3333 rational_set (cbasic_operand2 , num_basic , den_basic );
3434
@@ -66,6 +66,19 @@ void sympify(VALUE operand2, basic_struct *cbasic_operand2) {
6666 }
6767}
6868
69+ void get_symintfromval (VALUE operand2 , basic_struct * cbasic_operand2 )
70+ {
71+ if ( TYPE (operand2 ) == T_FIXNUM ){
72+ int i = NUM2INT ( operand2 );
73+ integer_set_si (cbasic_operand2 , i );
74+ } else if ( TYPE (operand2 ) == T_BIGNUM ){
75+ VALUE Rb_Temp_String = rb_funcall (operand2 , rb_intern ("to_s" ), 0 , NULL );
76+ integer_set_str (cbasic_operand2 , StringValueCStr (Rb_Temp_String ));
77+ } else {
78+ rb_raise (rb_eTypeError , "Invalid Type: Fixnum or Bignum required" );
79+ }
80+ }
81+
6982VALUE Klass_of_Basic (const basic_struct * basic_ptr ) {
7083 switch (basic_get_type (basic_ptr )) {
7184 case SYMENGINE_SYMBOL :
0 commit comments