@@ -296,7 +296,7 @@ abstract static class AddNode extends PythonBinaryBuiltinNode {
296296
297297 @ Specialization
298298 double doDPi (double left , PInt right ) {
299- return left + right .doubleValue ( );
299+ return left + right .doubleValueWithOverflow ( getRaiseNode () );
300300 }
301301
302302 @ Specialization
@@ -345,7 +345,7 @@ abstract static class SubNode extends PythonBinaryBuiltinNode {
345345
346346 @ Specialization
347347 double doDPi (double left , PInt right ) {
348- return left - right .doubleValue ( );
348+ return left - right .doubleValueWithOverflow ( getRaiseNode () );
349349 }
350350
351351 @ Specialization
@@ -355,7 +355,7 @@ abstract static class SubNode extends PythonBinaryBuiltinNode {
355355
356356 @ Specialization
357357 double doPiD (PInt left , double right ) {
358- return left .doubleValue ( ) - right ;
358+ return left .doubleValueWithOverflow ( getRaiseNode () ) - right ;
359359 }
360360
361361 @ SuppressWarnings ("unused" )
@@ -382,7 +382,7 @@ abstract static class MulNode extends PythonBinaryBuiltinNode {
382382
383383 @ Specialization
384384 double doDP (double left , PInt right ) {
385- return left * right .doubleValue ( );
385+ return left * right .doubleValueWithOverflow ( getRaiseNode () );
386386 }
387387
388388 @ Specialization
@@ -412,7 +412,7 @@ Object doDP(VirtualFrame frame, PythonNativeObject left, PInt right,
412412 @ Cached FromNativeSubclassNode getFloat ) {
413413 Double leftPrimitive = getFloat .execute (frame , left );
414414 if (leftPrimitive != null ) {
415- return leftPrimitive * right .doubleValue ( );
415+ return leftPrimitive * right .doubleValueWithOverflow ( getRaiseNode () );
416416 } else {
417417 return PNotImplemented .NOT_IMPLEMENTED ;
418418 }
@@ -440,7 +440,7 @@ abstract static class PowerNode extends PythonTernaryBuiltinNode {
440440 @ Specialization
441441 double doDPi (double left , PInt right , @ SuppressWarnings ("unused" ) PNone none ,
442442 @ Shared ("negativeRaise" ) @ Cached BranchProfile negativeRaise ) {
443- return doOperation (left , right .doubleValue ( ), negativeRaise );
443+ return doOperation (left , right .doubleValueWithOverflow ( getRaiseNode () ), negativeRaise );
444444 }
445445
446446 /**
@@ -519,14 +519,14 @@ Object doDLComplex(VirtualFrame frame, long left, double right, PNone none,
519519 double doDPi (VirtualFrame frame , PInt left , double right , @ SuppressWarnings ("unused" ) PNone none ,
520520 @ Shared ("powCall" ) @ Cached ("create(__POW__)" ) LookupAndCallTernaryNode callPow ,
521521 @ Shared ("negativeRaise" ) @ Cached BranchProfile negativeRaise ) throws UnexpectedResultException {
522- return doDD (frame , left .doubleValue ( ), right , none , callPow , negativeRaise );
522+ return doDD (frame , left .doubleValueWithOverflow ( getRaiseNode () ), right , none , callPow , negativeRaise );
523523 }
524524
525525 @ Specialization (replaces = "doDPi" )
526526 Object doDPiToComplex (VirtualFrame frame , PInt left , double right , @ SuppressWarnings ("unused" ) PNone none ,
527527 @ Shared ("powCall" ) @ Cached ("create(__POW__)" ) LookupAndCallTernaryNode callPow ,
528528 @ Shared ("negativeRaise" ) @ Cached BranchProfile negativeRaise ) {
529- return doDDToComplex (frame , left .doubleValue ( ), right , none , callPow , negativeRaise );
529+ return doDDToComplex (frame , left .doubleValueWithOverflow ( getRaiseNode () ), right , none , callPow , negativeRaise );
530530 }
531531
532532 @ Specialization
@@ -571,7 +571,7 @@ abstract static class FloorDivNode extends FloatBinaryBuiltinNode {
571571 @ Specialization
572572 double doDL (double left , PInt right ) {
573573 raiseDivisionByZero (right .isZero ());
574- return Math .floor (left / right .doubleValue ( ));
574+ return Math .floor (left / right .doubleValueWithOverflow ( getRaiseNode () ));
575575 }
576576
577577 @ Specialization
@@ -589,7 +589,7 @@ abstract static class FloorDivNode extends FloatBinaryBuiltinNode {
589589 @ Specialization
590590 double doPiD (PInt left , double right ) {
591591 raiseDivisionByZero (right == 0.0 );
592- return Math .floor (left .doubleValue ( ) / right );
592+ return Math .floor (left .doubleValueWithOverflow ( getRaiseNode () ) / right );
593593 }
594594
595595 @ SuppressWarnings ("unused" )
@@ -833,7 +833,7 @@ abstract static class DivNode extends FloatBinaryBuiltinNode {
833833
834834 @ Specialization
835835 double doDPi (double left , PInt right ) {
836- return left / right .doubleValue ( );
836+ return left / right .doubleValueWithOverflow ( getRaiseNode () );
837837 }
838838
839839 @ Specialization
@@ -843,7 +843,7 @@ abstract static class DivNode extends FloatBinaryBuiltinNode {
843843
844844 @ Specialization
845845 double div (PInt left , double right ) {
846- return left .doubleValue ( ) / right ;
846+ return left .doubleValueWithOverflow ( getRaiseNode () ) / right ;
847847 }
848848
849849 @ Specialization
@@ -937,7 +937,7 @@ boolean eqDbLn(double a, long b) {
937937
938938 @ Specialization
939939 boolean eqDbPI (double a , PInt b ) {
940- return a == b .doubleValue ();
940+ return Double . isFinite ( a ) && a == b .doubleValue ();
941941 }
942942
943943 @ Specialization
@@ -955,7 +955,7 @@ Object eqPDb(VirtualFrame frame, PythonNativeObject left, long right,
955955 @ Specialization
956956 Object eqPDb (VirtualFrame frame , PythonNativeObject left , PInt right ,
957957 @ Cached FromNativeSubclassNode getFloat ) {
958- return getFloat .execute (frame , left ) == right . doubleValue ( );
958+ return eqDbPI ( getFloat .execute (frame , left ), right );
959959 }
960960
961961 @ Fallback
@@ -981,7 +981,7 @@ boolean neDbLn(double a, long b) {
981981
982982 @ Specialization
983983 boolean neDbPI (double a , PInt b ) {
984- return a != b .doubleValue ();
984+ return !( Double . isFinite ( a ) && a == b .doubleValue () );
985985 }
986986
987987 @ Specialization
@@ -999,7 +999,7 @@ Object eqPDb(VirtualFrame frame, PythonNativeObject left, long right,
999999 @ Specialization
10001000 Object eqPDb (VirtualFrame frame , PythonNativeObject left , PInt right ,
10011001 @ Cached FromNativeSubclassNode getFloat ) {
1002- return getFloat .execute (frame , left ) != right . doubleValue ( );
1002+ return neDbPI ( getFloat .execute (frame , left ), right );
10031003 }
10041004
10051005 @ Fallback
0 commit comments