@@ -6,11 +6,17 @@ void sympify(VALUE operand2, basic_struct *cbasic_operand2) {
66 basic_struct * temp ;
77 VALUE new_operand2 , num , den ;
88 VALUE real , imag ;
9+ double f ;
910
1011 switch (TYPE (operand2 )) {
1112 case T_FIXNUM :
1213 case T_BIGNUM :
13- GET_SYMINTFROMVAL (operand2 , cbasic_operand2 );
14+ get_symintfromval (operand2 , cbasic_operand2 );
15+ break ;
16+
17+ case T_FLOAT :
18+ f = RFLOAT_VALUE (operand2 );
19+ real_double_set_d (cbasic_operand2 , f );
1420 break ;
1521
1622 case T_RATIONAL :
@@ -21,8 +27,8 @@ void sympify(VALUE operand2, basic_struct *cbasic_operand2) {
2127 basic_new_stack (num_basic );
2228 basic_new_stack (den_basic );
2329
24- GET_SYMINTFROMVAL (num , num_basic );
25- GET_SYMINTFROMVAL (den , den_basic );
30+ get_symintfromval (num , num_basic );
31+ get_symintfromval (den , den_basic );
2632
2733 rational_set (cbasic_operand2 , num_basic , den_basic );
2834
@@ -60,12 +66,27 @@ void sympify(VALUE operand2, basic_struct *cbasic_operand2) {
6066 }
6167}
6268
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+
6382VALUE Klass_of_Basic (const basic_struct * basic_ptr ) {
6483 switch (basic_get_type (basic_ptr )) {
6584 case SYMENGINE_SYMBOL :
6685 return c_symbol ;
6786 case SYMENGINE_INTEGER :
6887 return c_integer ;
88+ case SYMENGINE_REAL_DOUBLE :
89+ return c_real_double ;
6990 case SYMENGINE_RATIONAL :
7091 return c_rational ;
7192 case SYMENGINE_COMPLEX :
0 commit comments