包详细信息

chopcal

okunishinishi182MIT3.0.3

Chop numbers.

math, chop, number

自述文件

chopcal

Build Status npm Version JS Standard

Chop numbers.

Installation

$ npm install chopcal --save

Usage

"use strict";

const chopcal = require('chopcal')

//------------------------
// ceil
//------------------------
console.log(chopcal.ceil(14, 10)) //-> 20
console.log(chopcal.ceil(16, 10)) //-> 20
console.log(chopcal.ceil(0.23, 0.1)) //-> 0.3
console.log(chopcal.ceil(0.27, 0.1)) //-> 0.3

//------------------------
// floor
//------------------------
console.log(chopcal.floor(14, 10)) //-> 10
console.log(chopcal.floor(16, 10)) //-> 10
console.log(chopcal.floor(0.23, 0.1)) //-> 0.2
console.log(chopcal.floor(0.27, 0.1)) //-> 0.2

//------------------------
// round
//------------------------
console.log(chopcal.round(14, 10)) //-> 10
console.log(chopcal.round(16, 10)) //-> 20
console.log(chopcal.round(0.23, 0.1)) //-> 0.2
console.log(chopcal.round(0.27, 0.1)) //-> 0.3

API

Signature Description
.ceil(val, base) Chop number to ceil.
.floor(val, base) Chop number to floor.
.round(val, base) Chop number to round.

License

This software is released under the MIT License.

Links