vuestic-ui
Version:
Vue 3 UI Framework
1 lines • 781 B
Source Map (JSON)
{"version":3,"file":"to-float.mjs","sources":["../../../../src/utils/to-float.ts"],"sourcesContent":["/**\n * Prevent floating numbers like 0.30000000000000004\n *\n * @example\n *\n * 0.1 + 0.2 // 0.30000000000000004\n *\n * safeFloat(0.1 + 0.2) // 0.3\n */\nexport const toFloat = (num: number) => {\n return Number(num.toPrecision(13))\n}\n\n/**\n * Check if the number is divisible by the step.\n * Consider the floating point error.\n */\nexport const isDividable = (num: number, step: number) => {\n const result = toFloat(num % step)\n\n return result === 0 || result === step\n}\n"],"names":[],"mappings":"AASa,MAAA,UAAU,CAAC,QAAgB;AACtC,SAAO,OAAO,IAAI,YAAY,EAAE,CAAC;AACnC;AAMa,MAAA,cAAc,CAAC,KAAa,SAAiB;AAClD,QAAA,SAAS,QAAQ,MAAM,IAAI;AAE1B,SAAA,WAAW,KAAK,WAAW;AACpC;"}