| 1234567891011121314151617181920212223242526272829303132333435 | /** * Created by Tony on 2017/3/28. */let test = require('tape');// test('test javascript rounding: ', function (t) {//     let f1 = 2.35, f2 = 2.45, f3 = 2.449999999999999995, f4 = 2.44999999999999995;//     t.equal(Math.round(f1*10), 24);//     t.equal(Math.round(f2*10), 25);//     t.equal(Math.round(f3*10), 25);//     t.equal(Math.round(f4*10), 25);//     t.end();// });//// test('test javascript fixed rounding: ', function (t) {//     let f1 = 2.35, f2 = 2.45, f3 = 2.449995;//     t.equal(f1.toFixed(1), '2.4');//     t.equal(f2.toFixed(1), '2.5');//     t.equal(f3.toFixed(1), '2.5');//     t.end();// });//test('test javascript decimal: ', function (t) {//    let x = new Decimal(0.1), y = new Decimal(0.2);//    t.equal(x + y, 0.3);//    t.end();//});test('test javascript decimal: ', function (t) {   let x = '3.44999999999';   t.equal(parseFloat(x).toFixed(1), `3.5`);   t.equal(parseFloat(x).toFixed(6), `3.450000`);    t.equal(parseFloat(parseFloat(x).toFixed(6)).toFixed(1), `3.5`);   t.end();});
 |