@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
20 lines • 697 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.bigint2number = bigint2number;
exports.roundToDecimals = roundToDecimals;
/**
* Converts a bigint (or string representation of a bigint) to a number by removing the trailing `n`.
* Please note that this can lead to loss of precision for very large bigints.
*/
function bigint2number(a) {
// we have to remove the trailing `n`
return Number(String(a).slice(0, -1));
}
/**
* Rounds a number to the specified number of decimal places.
*/
function roundToDecimals(value, decimals) {
const factor = 10 ** decimals;
return Math.round(value * factor) / factor;
}
//# sourceMappingURL=numbers.js.map