@techmely/utils
Version:
Collection of helpful JavaScript / TypeScript utils
28 lines (23 loc) • 588 B
JavaScript
/*!
* @techmely/utils
* Copyright(c) 2021-2024 Techmely <techmely.creation@gmail.com>
* MIT Licensed
*/
import {
digitLengthPrecision
} from "./chunk-HHTSEVTB.mjs";
import {
stripPrecision
} from "./chunk-GPTFO2E2.mjs";
// src/numberFloat2FixedPrecision.ts
function float2FixedPrecision(num) {
if (num.toString().indexOf("e") === -1) {
return Number(num.toString().replace(".", ""));
}
const dLen = digitLengthPrecision(num);
const powDLen = 10 ** dLen;
return dLen > 0 ? stripPrecision(Number(num) * powDLen) : Number(num);
}
export {
float2FixedPrecision
};