devextreme
Version:
HTML5 JavaScript Component Suite for Responsive Web Development
30 lines (27 loc) • 960 B
JavaScript
/**
* DevExtreme (esm/localization/utils.js)
* Version: 23.2.6
* Build date: Wed May 01 2024
*
* Copyright (c) 2012 - 2024 Developer Express Inc. ALL RIGHTS RESERVED
* Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
*/
import {
sign,
multiplyInExponentialForm
} from "../core/utils/math";
var DECIMAL_BASE = 10;
function roundByAbs(value) {
var valueSign = sign(value);
return valueSign * Math.round(Math.abs(value))
}
function adjustValue(value, precision) {
var precisionMultiplier = Math.pow(DECIMAL_BASE, precision);
var intermediateValue = multiplyInExponentialForm(value, precision);
return roundByAbs(intermediateValue) / precisionMultiplier
}
export function toFixed(value, precision) {
var valuePrecision = precision || 0;
var adjustedValue = valuePrecision > 0 ? adjustValue(...arguments) : value;
return adjustedValue.toFixed(valuePrecision)
}