# std: Implement more useful approxEq semantics · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/ff14451b4a328ca6862637a88912000d11aa2bf3)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: ff14451b4a328ca6862637a88912000d11aa2bf3

Requested commit: ff14451b4a328ca6862637a88912000d11aa2bf3

Commit: ff14451b4a328ca6862637a88912000d11aa2bf3

Tree: a4a0ea4799d4765b7b15d1b55d20235cb87f9ef4

Author: LemonBoy

Committer: LemonBoy

## Message

```
std: Implement more useful approxEq semantics

Comparisons with absolute epsilons are usually useful when comparing
numbers to zero, for non-zero numbers it's advised to switch to relative
epsilons instead to obtain meaningful results (check [1] for more
details).

The new API introduces approxEqAbs and approxEqRel, where the former
aliases and deprecated the old `approxEq`, allowing the user to pick the
right tool for the job.

The documentation is meant to guide the user in the choice of the
correct alternative.

[1] https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/

```

## Parents

- [17837affd22a6055c65a14252fa38610fdeabc3a](https://git.cafe/gitcafe/zig/commit/17837affd22a6055c65a14252fa38610fdeabc3a?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/ff14451b4a328ca6862637a88912000d11aa2bf3?format=markdown)
