Vue数据精度

//引用插件  math

npm install mathjs

全局声明 

//声明全局  

import * as math from "mathjs";
Vue.prototype.$math = math;

 基础使用

//math基础使用

this.$math.add(a,b)//加
this.$math.subtract(a,b)//减
this.$math.multiply(a,b)//乘
this.$math.divide(a,b)//除

对字符串表达式进行求值运算

this.$math.eval('12 / (2.3 + 0.7)');    // 4
this.$math.eval('12.7 cm to inch');     // 5 inch
this.$math.eval('sin(45 deg) ^ 2');     // 0.5
this.$math.eval('9 / 3 + 2i');          // 3 + 2i
this.$math.eval('det([-1, 2; 3, 1])');  // -7

链式操作

this.$math.chain(3)
    .add(4)
    .multiply(2)
    .done(); // 14

矩阵操作 

var n = this.$math.matrix([[4,3,2], [6,6,8], [7,4,5]]);   
console.log(n.valueof()); // [[4,3,2],[6,6,8],[7,4,5]]

math.js文档地址:http://mathjs.org/docs/index.html 

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值