@@ -213,9 +213,7 @@ public static function process_callback($_get)
213213 }
214214
215215 foreach ($ params as &$ val ) {
216- //if(is_string($val)) {
217- $ val = trim ($ val );
218- //}
216+ $ val = is_string ($ val ) ? trim ($ val ) : null ;
219217 }
220218
221219 return $ params ;
@@ -266,17 +264,16 @@ public static function get_estimate($coin, $api_key)
266264
267265 public static function sig_fig ($ value , $ digits )
268266 {
269- if ($ value == 0 ) {
270- $ decimalPlaces = $ digits - 1 ;
271- } elseif ($ value < 0 ) {
272- $ decimalPlaces = $ digits - floor (log10 ($ value * -1 )) - 1 ;
273- } else {
274- $ decimalPlaces = $ digits - floor (log10 ($ value )) - 1 ;
267+ $ value = (string ) $ value ;
268+ if (strpos ($ value , '. ' ) !== false ) {
269+ if ($ value [0 ] != '- ' ) {
270+ return bcadd ($ value , '0. ' . str_repeat ('0 ' , $ digits ) . '5 ' , $ digits );
271+ }
272+
273+ return bcsub ($ value , '0. ' . str_repeat ('0 ' , $ digits ) . '5 ' , $ digits );
275274 }
276275
277- $ answer = ($ decimalPlaces > 0 ) ?
278- number_format ($ value , $ decimalPlaces , '. ' , '' ) : round ($ value , $ decimalPlaces );
279- return $ answer ;
276+ return $ value ;
280277 }
281278
282279 public static function calc_order ($ history , $ total , $ total_fiat ): array
0 commit comments