File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,6 @@ class Float extends AbstractType
3232 /** @var string $mathConstant Mathematical constant name */
3333 protected $ mathConstant = null ;
3434
35-
3635 /**
3736 * Constructor.
3837 */
@@ -112,8 +111,15 @@ public function detectMathConstant($var, $precision)
112111 );
113112
114113 foreach ($ constants as $ name => $ item ) {
115- if (0 === bccomp ($ var , $ item ['value ' ], max ($ precision - 1 , $ item ['min_precision ' ]))) {
116- return $ name ;
114+ if (extension_loaded ('bcmath ' )) {
115+ if (0 === bccomp ($ var , $ item ['value ' ], max ($ precision - 1 , $ item ['min_precision ' ]))) {
116+ return $ name ;
117+ }
118+ } else {
119+ $ p = max ($ precision - 1 , $ item ['min_precision ' ]);
120+ if (number_format ($ var , $ p ) === number_format ($ item ['value ' ], $ p )) {
121+ return $ name ;
122+ }
117123 }
118124 }
119125
@@ -125,5 +131,4 @@ public function getDecimals()
125131 return $ this ->decimals ;
126132 }
127133
128-
129134}
You can’t perform that action at this time.
0 commit comments