botbook/node_modules/json-schema-library/dist/module/lib/utils/getPrecision.js

9 lines
242 B
JavaScript
Raw Normal View History

2024-09-04 13:13:15 -03:00
/**
* returns the floating point precision of a decimal number or 0
*/
export function getPrecision(value) {
const string = `${value}`;
const index = string.indexOf(".");
return index === -1 ? 0 : string.length - (index + 1);
}