botbook/node_modules/json-schema-library/lib/utils/getPrecision.ts
Rodrigo Rodriguez 6ae15fe3e5 Updated.
2024-09-04 13:13:15 -03:00

8 lines
258 B
TypeScript

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