温馨提示:本站仅提供公开网络链接索引服务,不存储、不篡改任何第三方内容,所有内容版权归原作者所有
AI智能索引来源:http://www.bun.com/reference/bun/test/Matchers/toBeCloseTo
点击访问原文链接

Matchers.toBeCloseTo method | bun:test module | Bun

Matchers.toBeCloseTo method | bun:test module | BunBuildDocsReferenceGuidesBlogDiscord/bun:test/Matchers/toBeCloseToMtoBeCloseTo

Search the reference...

/

BuildDocsReferenceGuidesBlogDiscord/bun:test/Matchers/toBeCloseToMtoBeCloseTo

method

test.Matchers.toBeCloseTotoBeCloseTo(expected: number,numDigits?: number): void;Asserts that value is close to the expected by floating point precision.

For example, the following fails because arithmetic on decimal (base 10) values often have rounding errors in limited precision binary (base 2) representation.

@param expectedthe expected value

@param numDigitsthe number of digits to check after the decimal point. Default is 2

expect(0.2 + 0.1).toBe(0.3); // fails Use `toBeCloseTo` to compare floating point numbers for approximate equality.

Resources

ReferenceDocsGuidesDiscordMerch StoreGitHubBlog 

Toolkit

RuntimePackage managerTest runnerBundlerPackage runner

Project

Bun 1.0Bun 1.1Bun 1.2Bun 1.3RoadmapContributingLicenseBaked with ❤️ in San Francisco

We're hiring →

智能索引记录