MCPcopy Create free account
hub / github.com/apitable/apitable / float2Fixed

Function float2Fixed

packages/core/src/utils/number.ts:265–271  ·  view source on GitHub ↗
(num: number)

Source from the content-addressed store, hash-verified

263
264// Scale the float to an integer,
265export function float2Fixed(num: number): number {
266 if (num.toString().indexOf('e') === -1) {
267 return Number(num.toString().replace('.', ''));
268 }
269 const dLen = digitLength(num);
270 return dLen > 0 ? strip(Number(num) * Math.pow(10, dLen)) : Number(num);
271}
272
273/**
274 * Exact multiplication (to resolve loss of precision)

Callers 2

timesFunction · 0.85
divideFunction · 0.85

Calls 4

digitLengthFunction · 0.85
stripFunction · 0.85
toStringMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected