@@ -186,8 +186,8 @@ public static function fromString($strValue, $scale = null)
186
186
if (preg_match ('/^([+\-]?)0*(([1-9][0-9]*|[0-9])(\.[0-9]+)?)$/ ' , $ strValue , $ captures ) === 1 ) {
187
187
188
188
// Now it's time to strip leading zeros in order to normalize inner values
189
- $ sign = ( $ captures [ 1 ]=== '' ) ? ' + ' : $ captures [1 ];
190
- $ value = $ captures [2 ];
189
+ $ sign = $ captures [1 ];
190
+ $ value = $ sign . $ captures [2 ];
191
191
192
192
$ dec_scale = $ scale !== null ?
193
193
$ scale :
@@ -196,7 +196,7 @@ public static function fromString($strValue, $scale = null)
196
196
} elseif (preg_match ('/([+\-]?)([0-9](\.[0-9]+)?)[eE]([+\-]?)([1-9][0-9]*)/ ' , $ strValue , $ captures ) === 1 ) {
197
197
198
198
// Now it's time to "unroll" the exponential notation to basic positional notation
199
- $ sign = ( $ captures [ 1 ]=== '' ) ? ' + ' : $ captures [1 ];
199
+ $ sign = $ captures [1 ];
200
200
$ mantissa = $ captures [2 ];
201
201
202
202
$ mantissa_scale = strlen ($ captures [3 ]) > 0 ? strlen ($ captures [3 ])-1 : 0 ;
@@ -212,7 +212,7 @@ public static function fromString($strValue, $scale = null)
212
212
$ tmp_multiplier = bcpow (10 , -$ exp_val , $ exp_val );
213
213
}
214
214
215
- $ value = bcmul ($ mantissa , $ tmp_multiplier , max ($ min_scale , $ scale !== null ? $ scale : 0 ));
215
+ $ value = $ sign . bcmul ($ mantissa , $ tmp_multiplier , max ($ min_scale , $ scale !== null ? $ scale : 0 ));
216
216
$ dec_scale = $ scale !== null ? $ scale : $ min_scale ;
217
217
218
218
} else {
@@ -221,10 +221,6 @@ public static function fromString($strValue, $scale = null)
221
221
);
222
222
}
223
223
224
- if ($ sign === '- ' ) {
225
- $ value = '- ' .$ value ;
226
- }
227
-
228
224
if ($ scale !== null ) {
229
225
$ value = self ::innerRound ($ value , $ scale );
230
226
}
0 commit comments