API Reference
@univerjs
@univerjs/engine-formula
functions
Strip

@univerjs/engine-formula v0.1.17Docs


Function: strip()

function strip(num, precision): number

Complete the number to the specified accuracy and solve the accuracy error,

e.g. strip(0.30000000000000004,15) => 0.3

Why precision is 15?

Excel only saves 15 digits

reference: https://stackoverflow.com/questions/1458633/how-to-deal-with-floating-point-number-precision-in-javascript (opens in a new tab)

Parameters

ParameterTypeDefault value
numnumberundefined
precisionnumber15

Returns

number

Defined in

packages/engine-formula/src/engine/utils/math-kit.ts:173 (opens in a new tab)


Copyright © 2021-2024 DreamNum Co,Ltd. All Rights Reserved.