@@ -648,7 +648,32 @@ public final RubyNumeric op_div(ThreadContext context, RubyInteger other) {
648
648
@ Override
649
649
@ JRubyMethod (name = "fdiv" )
650
650
public IRubyObject fdiv (ThreadContext context , IRubyObject other ) {
651
- return f_div (context , f_to_f (context , this ), other );
651
+ if (other instanceof RubyInteger ) {
652
+ if (f_zero_p (context , other )) {
653
+ throw context .runtime .newZeroDivisionError ();
654
+ } else {
655
+ return f_muldiv (context , getMetaClass (),
656
+ num , den ,
657
+ (RubyInteger ) other , RubyFixnum .one (context .runtime ), false );
658
+ }
659
+ } else if (other instanceof RubyFloat ) {
660
+ return dbl2num (context .runtime , getDoubleValue () / ((RubyFloat ) other ).getDoubleValue ());
661
+ } else if (other instanceof RubyRational ) {
662
+ if (f_zero_p (context , other )) {
663
+ throw context .runtime .newZeroDivisionError ();
664
+ } else {
665
+ if (f_one_p (context , this )) {
666
+ return newRationalNoReduce (context , getMetaClass (),
667
+ ((RubyRational ) other ).num , ((RubyRational ) other ).den );
668
+ }
669
+
670
+ return f_muldiv (context , getMetaClass (),
671
+ num , den ,
672
+ ((RubyRational ) other ).num , ((RubyRational ) other ).den , false );
673
+ }
674
+ } else {
675
+ return coerceBin (context , sites (context ).op_quo , other );
676
+ }
652
677
}
653
678
654
679
/** nurat_expt
0 commit comments