almost-equal

WebJar for almost-equal

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

almost-equal
Last Version

Last Version

1.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

almost-equal
WebJar for almost-equal
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/scijs/almost-equal

Download almost-equal

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/almost-equal/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>almost-equal</artifactId>
    <version>1.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/almost-equal/
implementation 'org.webjars.npm:almost-equal:1.1.0'
// https://jarcasting.com/artifacts/org.webjars.npm/almost-equal/
implementation ("org.webjars.npm:almost-equal:1.1.0")
'org.webjars.npm:almost-equal:jar:1.1.0'
<dependency org="org.webjars.npm" name="almost-equal" rev="1.1.0">
  <artifact name="almost-equal" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='almost-equal', version='1.1.0')
)
libraryDependencies += "org.webjars.npm" % "almost-equal" % "1.1.0"
[org.webjars.npm/almost-equal "1.1.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

almost-equal

Checks when two floats are almost equal.

Use

First install using npm:

npm install almost-equal

Then use as follows:

var almostEqual = require("almost-equal")

var a = 100
  , b = 100 + 1e-12

//Check if a == b up to float precision
console.log(almostEqual(a, b, almostEqual.FLT_EPSILON, almostEqual.FLT_EPSILON))

//Check if a == b up to double precision
console.log(almostEqual(a, b, almostEqual.DBL_EPSILON, almostEqual.DBL_EPSILON))

almostEqual(a, b[, absoluteTolerance [, relativeTolerance]])

Checks if two floats are within the given tolerances of one another using the formula:

|a - b| < max(absoluteTolerance, min(|a|, |b|) * relativeTolerance)
  • a and b are the two numbers to comapre
  • absoluteTolerance is a fixed minimal tolerance (set to 0 to ignore)
  • relativeTolerance is a tolerance that scales with a/b (set to 0 to ignore)

Returns true if a and b are approximately equal.

If tolerance argument is omitted, almostEqual.DBL_EPSILON value is used by default.

almostEqual.FLT_EPSILON

Floating point (32-bit) epsilon

almostEqual.DBL_EPSILON

Double precision (64-bit) epsilon

Credits

(c) 2013 Mikola Lysenko. MIT License

org.webjars.npm

Versions

Version
1.1.0