You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by GitBox <gi...@apache.org> on 2019/09/18 08:06:24 UTC

[GitHub] [incubator-echarts] 100pah commented on issue #11249: quantityExponent方法存在精度问题

100pah commented on issue #11249: quantityExponent方法存在精度问题
URL: https://github.com/apache/incubator-echarts/issues/11249#issuecomment-532571235
 
 
   A possible solution might be: 
   
   ```js
   function quantityExponent(val) {
       var exp = Math.floor(Math.log(val) / Math.LN10);
       if (val / Math.pow(10, exp) >= 10) {
           exp++;
       }
       return exp;
   }
   ```
   
   BTW, we also need to consider `quantityExponent(0)`.
   And write test cases for this util.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org