UNPKG

locutus

Version:

Locutus other languages' standard libraries to JavaScript for fun and educational purposes

25 lines (24 loc) 733 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.bcscale = bcscale; const _bc_ts_1 = require("../_helpers/_bc.js"); function bcscale(scale) { // discuss at: https://locutus.io/php/bcscale/ // original by: lmeyrick (https://sourceforge.net/projects/bcmath-js/) // example 1: bcscale(1) // returns 1: 0 const libbcmath = (0, _bc_ts_1._bc)(); const oldScale = libbcmath.scale; if (scale == null) { return oldScale; } const parsedScale = Number.parseInt(String(scale), 10); if (Number.isNaN(parsedScale)) { return false; } if (parsedScale < 0) { return false; } libbcmath.scale = parsedScale; return oldScale; }