@@ -49,9 +49,9 @@ public class CmathModuleBuiltins extends PythonBuiltins {
49
49
static final double P12 = 0.5 * Math .PI ;
50
50
static final double P34 = 0.75 * Math .PI ;
51
51
52
- static final double largeDouble = Double .MAX_VALUE / 4.0 ; // used to avoid overflow
53
- static final double ln2 = 0.6931471805599453094 ; // natural log of 2
54
- static final double ln10 = 2.302585092994045684 ; // natural log of 10
52
+ static final double LARGE_DOUBLE = Double .MAX_VALUE / 4.0 ; // used to avoid overflow
53
+ static final double LN_2 = 0.6931471805599453094 ; // natural log of 2
54
+ static final double LN_10 = 2.302585092994045684 ; // natural log of 10
55
55
56
56
@ Override
57
57
protected List <? extends NodeFactory <? extends PythonBuiltinBaseNode >> getNodeFactories () {
@@ -437,13 +437,13 @@ private double computeRealPart(double real, double imag) {
437
437
double ax = Math .abs (real );
438
438
double ay = Math .abs (imag );
439
439
440
- if (ax > largeDouble || ay > largeDouble ) {
441
- return Math .log (Math .hypot (ax / 2.0 , ay / 2.0 )) + ln2 ;
440
+ if (ax > LARGE_DOUBLE || ay > LARGE_DOUBLE ) {
441
+ return Math .log (Math .hypot (ax / 2.0 , ay / 2.0 )) + LN_2 ;
442
442
}
443
443
if (ax < Double .MIN_NORMAL && ay < Double .MIN_NORMAL ) {
444
444
if (ax > 0.0 || ay > 0.0 ) {
445
445
final double scaleUp = 0x1.0p53 ;
446
- return Math .log (Math .hypot (ax * scaleUp , ay * scaleUp )) - 53 * ln2 ;
446
+ return Math .log (Math .hypot (ax * scaleUp , ay * scaleUp )) - 53 * LN_2 ;
447
447
}
448
448
throw raise (ValueError , ErrorMessages .MATH_DOMAIN_ERROR );
449
449
}
@@ -467,7 +467,7 @@ abstract static class Log10Node extends PythonUnaryBuiltinNode {
467
467
@ Specialization
468
468
PComplex doComplex (VirtualFrame frame , PComplex z ) {
469
469
PComplex r = logNode .executeComplex (frame , z , PNone .NO_VALUE );
470
- return factory ().createComplex (r .getReal () / ln10 , r .getImag () / ln10 );
470
+ return factory ().createComplex (r .getReal () / LN_10 , r .getImag () / LN_10 );
471
471
}
472
472
473
473
@ Specialization
@@ -559,9 +559,9 @@ PComplex compute(VirtualFrame frame, double real, double imag) {
559
559
560
560
double rreal ;
561
561
double rimag ;
562
- if (Math .abs (real ) > largeDouble || Math .abs (imag ) > largeDouble ) {
562
+ if (Math .abs (real ) > LARGE_DOUBLE || Math .abs (imag ) > LARGE_DOUBLE ) {
563
563
rreal = Math .atan2 (Math .abs (imag ), real );
564
- double s = Math .log (Math .hypot (real / 2.0 , imag / 2.0 )) + ln2 * 2.0 ;
564
+ double s = Math .log (Math .hypot (real / 2.0 , imag / 2.0 )) + LN_2 * 2.0 ;
565
565
if (real < 0.0 ) {
566
566
rimag = -Math .copySign (s , imag );
567
567
} else {
0 commit comments