MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / decimalAdjust

Function decimalAdjust

web/pgadmin/static/js/utils.js:691–708  ·  view source on GitHub ↗

* Decimal adjustment of a number. * * @param {String} type The type of adjustment. * @param {Number} value The number. * @param {Integer} exp The exponent (the 10 logarithm of the adjustment base). * @returns {Number} The adjusted value.

(type, value, exp)

Source from the content-addressed store, hash-verified

689 * @returns {Number} The adjusted value.
690 */
691function decimalAdjust(type, value, exp) {
692 // If the exp is undefined or zero...
693 if (typeof exp === 'undefined' || +exp === 0) {
694 return Math[type](value);
695 }
696 value = +value;
697 exp = +exp;
698 // If the value is not a number or the exp is not an integer...
699 if (isNaN(value) || exp % 1 !== 0) {
700 return NaN;
701 }
702 // Shift
703 value = value.toString().split('e');
704 value = Math[type](+(value[0] + 'e' + (value[1] ? (+value[1] - exp) : -exp)));
705 // Shift back
706 value = value.toString().split('e');
707 return +(value[0] + 'e' + (value[1] ? (+value[1] + exp) : exp));
708}
709
710// Decimal round
711if (!Math.round10) {

Callers 1

utils.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected