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

@univerjs/engine-formula v0.4.2Docs


Function: stripErrorMargin()

function stripErrorMargin(
   num, 
   precision, 
   tolerance): number

Tolerance for the results of accuracy issues to tolerate certain errors

Why is precision 12? This is an empirical choice. Generally, choosing 12 can solve most of the 0001 and 0009 problems. e.g. floor(5,1.23) = 0.0800000000000001

why is tolerance 1e-10? Since the value of Number.EPSILON is too small to be applicable to all floating-point precision processing, for most application scenarios, the error range of 1e-10 can tolerate common floating-point errors. For example, =30.2 - 30 displayed as 0.2 in Excel

Parameters

ParameterTypeDefault value
numnumberundefined
precisionnumber12
tolerancenumber1e-10

Returns

number

Defined in

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


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