UNPKG

devextreme

Version:

HTML5 JavaScript Component Suite for Responsive Web Development

33 lines (29 loc) 1.08 kB
/** * DevExtreme (cjs/__internal/core/localization/utils.js) * Version: 25.2.3 * Build date: Fri Dec 12 2025 * * Copyright (c) 2012 - 2025 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.toFixed = toFixed; var _m_math = require("../../core/utils/m_math"); const DECIMAL_BASE = 10; function roundByAbs(value) { const valueSign = (0, _m_math.sign)(value); return valueSign * Math.round(Math.abs(value)) } function adjustValue(value, precision) { const precisionMultiplier = 10 ** precision; const intermediateValue = (0, _m_math.multiplyInExponentialForm)(value, precision); return roundByAbs(intermediateValue) / precisionMultiplier } function toFixed(value, precision) { const valuePrecision = precision ?? 0; const adjustedValue = valuePrecision > 0 ? adjustValue(value, valuePrecision) : value; return adjustedValue.toFixed(valuePrecision) }