@@ -296,7 +296,7 @@ abstract static class AddNode extends PythonBinaryBuiltinNode {
296
296
297
297
@ Specialization
298
298
double doDPi (double left , PInt right ) {
299
- return left + right .doubleValue ( );
299
+ return left + right .doubleValueWithOverflow ( getRaiseNode () );
300
300
}
301
301
302
302
@ Specialization
@@ -345,7 +345,7 @@ abstract static class SubNode extends PythonBinaryBuiltinNode {
345
345
346
346
@ Specialization
347
347
double doDPi (double left , PInt right ) {
348
- return left - right .doubleValue ( );
348
+ return left - right .doubleValueWithOverflow ( getRaiseNode () );
349
349
}
350
350
351
351
@ Specialization
@@ -355,7 +355,7 @@ abstract static class SubNode extends PythonBinaryBuiltinNode {
355
355
356
356
@ Specialization
357
357
double doPiD (PInt left , double right ) {
358
- return left .doubleValue ( ) - right ;
358
+ return left .doubleValueWithOverflow ( getRaiseNode () ) - right ;
359
359
}
360
360
361
361
@ SuppressWarnings ("unused" )
@@ -382,7 +382,7 @@ abstract static class MulNode extends PythonBinaryBuiltinNode {
382
382
383
383
@ Specialization
384
384
double doDP (double left , PInt right ) {
385
- return left * right .doubleValue ( );
385
+ return left * right .doubleValueWithOverflow ( getRaiseNode () );
386
386
}
387
387
388
388
@ Specialization
@@ -412,7 +412,7 @@ Object doDP(VirtualFrame frame, PythonNativeObject left, PInt right,
412
412
@ Cached FromNativeSubclassNode getFloat ) {
413
413
Double leftPrimitive = getFloat .execute (frame , left );
414
414
if (leftPrimitive != null ) {
415
- return leftPrimitive * right .doubleValue ( );
415
+ return leftPrimitive * right .doubleValueWithOverflow ( getRaiseNode () );
416
416
} else {
417
417
return PNotImplemented .NOT_IMPLEMENTED ;
418
418
}
@@ -440,7 +440,7 @@ abstract static class PowerNode extends PythonTernaryBuiltinNode {
440
440
@ Specialization
441
441
double doDPi (double left , PInt right , @ SuppressWarnings ("unused" ) PNone none ,
442
442
@ Shared ("negativeRaise" ) @ Cached BranchProfile negativeRaise ) {
443
- return doOperation (left , right .doubleValue ( ), negativeRaise );
443
+ return doOperation (left , right .doubleValueWithOverflow ( getRaiseNode () ), negativeRaise );
444
444
}
445
445
446
446
/**
@@ -519,14 +519,14 @@ Object doDLComplex(VirtualFrame frame, long left, double right, PNone none,
519
519
double doDPi (VirtualFrame frame , PInt left , double right , @ SuppressWarnings ("unused" ) PNone none ,
520
520
@ Shared ("powCall" ) @ Cached ("create(__POW__)" ) LookupAndCallTernaryNode callPow ,
521
521
@ 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 );
523
523
}
524
524
525
525
@ Specialization (replaces = "doDPi" )
526
526
Object doDPiToComplex (VirtualFrame frame , PInt left , double right , @ SuppressWarnings ("unused" ) PNone none ,
527
527
@ Shared ("powCall" ) @ Cached ("create(__POW__)" ) LookupAndCallTernaryNode callPow ,
528
528
@ 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 );
530
530
}
531
531
532
532
@ Specialization
@@ -571,7 +571,7 @@ abstract static class FloorDivNode extends FloatBinaryBuiltinNode {
571
571
@ Specialization
572
572
double doDL (double left , PInt right ) {
573
573
raiseDivisionByZero (right .isZero ());
574
- return Math .floor (left / right .doubleValue ( ));
574
+ return Math .floor (left / right .doubleValueWithOverflow ( getRaiseNode () ));
575
575
}
576
576
577
577
@ Specialization
@@ -589,7 +589,7 @@ abstract static class FloorDivNode extends FloatBinaryBuiltinNode {
589
589
@ Specialization
590
590
double doPiD (PInt left , double right ) {
591
591
raiseDivisionByZero (right == 0.0 );
592
- return Math .floor (left .doubleValue ( ) / right );
592
+ return Math .floor (left .doubleValueWithOverflow ( getRaiseNode () ) / right );
593
593
}
594
594
595
595
@ SuppressWarnings ("unused" )
@@ -833,7 +833,7 @@ abstract static class DivNode extends FloatBinaryBuiltinNode {
833
833
834
834
@ Specialization
835
835
double doDPi (double left , PInt right ) {
836
- return left / right .doubleValue ( );
836
+ return left / right .doubleValueWithOverflow ( getRaiseNode () );
837
837
}
838
838
839
839
@ Specialization
@@ -843,7 +843,7 @@ abstract static class DivNode extends FloatBinaryBuiltinNode {
843
843
844
844
@ Specialization
845
845
double div (PInt left , double right ) {
846
- return left .doubleValue ( ) / right ;
846
+ return left .doubleValueWithOverflow ( getRaiseNode () ) / right ;
847
847
}
848
848
849
849
@ Specialization
@@ -937,7 +937,7 @@ boolean eqDbLn(double a, long b) {
937
937
938
938
@ Specialization
939
939
boolean eqDbPI (double a , PInt b ) {
940
- return a == b .doubleValue ();
940
+ return Double . isFinite ( a ) && a == b .doubleValue ();
941
941
}
942
942
943
943
@ Specialization
@@ -955,7 +955,7 @@ Object eqPDb(VirtualFrame frame, PythonNativeObject left, long right,
955
955
@ Specialization
956
956
Object eqPDb (VirtualFrame frame , PythonNativeObject left , PInt right ,
957
957
@ Cached FromNativeSubclassNode getFloat ) {
958
- return getFloat .execute (frame , left ) == right . doubleValue ( );
958
+ return eqDbPI ( getFloat .execute (frame , left ), right );
959
959
}
960
960
961
961
@ Fallback
@@ -981,7 +981,7 @@ boolean neDbLn(double a, long b) {
981
981
982
982
@ Specialization
983
983
boolean neDbPI (double a , PInt b ) {
984
- return a != b .doubleValue ();
984
+ return !( Double . isFinite ( a ) && a == b .doubleValue () );
985
985
}
986
986
987
987
@ Specialization
@@ -999,7 +999,7 @@ Object eqPDb(VirtualFrame frame, PythonNativeObject left, long right,
999
999
@ Specialization
1000
1000
Object eqPDb (VirtualFrame frame , PythonNativeObject left , PInt right ,
1001
1001
@ Cached FromNativeSubclassNode getFloat ) {
1002
- return getFloat .execute (frame , left ) != right . doubleValue ( );
1002
+ return neDbPI ( getFloat .execute (frame , left ), right );
1003
1003
}
1004
1004
1005
1005
@ Fallback
0 commit comments