一個JavaScript的任意精度的十進制類型:decimal.js

jopen 10年前發布 | 59K 次閱讀 JavaScript開發 decimal.js

一個JavaScript的任意精度的十進制類型:decimal.js。

特性

  • 更快,更小,或許更容易使用比Java版本的BigDecimal
  • 簡單的API,但功能齊全
  • Replicates the toExponential, toFixed, toPrecision and toString methods of JavaScript's Number type
  • Includes a toFraction and correctly-rounded exp, ln, log and sqrt functions
  • Supports non-integer powers
  • Works with numbers with or without fraction digits in bases from 2 to 64 inclusive
  • No dependencies
  • Wide platform compatibility: uses JavaScript 1.5 (ECMAScript 3) features only
  • Comprehensive documentation and test set
  • 8 KB minified and gzipped
  • </ul>

    x = new Decimal(123.4567)
    y = new Decimal('123456.7e-3')
    z = new Decimal(x)
    x.equals(y) && y.equals(z) && x.equals(z)        // true

      一個JavaScript的任意精度的十進制類型:decimal.js

      項目主頁:http://www.baiduhome.net/lib/view/home/1417265889893

       

     本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
     轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
     本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!