mirror of
https://github.com/nim-lang/Nim.git
synced 2026-08-30 18:41:45 +00:00
Add Complex version of almostEqual function (#23549)
This adds a version of `almostEqual` (which was already available for floats) thata works with `Complex[SomeFloat]`. Proof that this is needed is that the first thing that the complex.nim runnable examples block did before this commit was define (an incomplete) `almostEqual` function that worked with complex values.
This commit is contained in:
@@ -84,6 +84,9 @@ let t = polar(a)
|
||||
doAssert(rect(t.r, t.phi) =~ a)
|
||||
doAssert(rect(1.0, 2.0) =~ complex(-0.4161468365471424, 0.9092974268256817))
|
||||
|
||||
doAssert(almostEqual(a, a + complex(1e-16, 1e-16)))
|
||||
doAssert(almostEqual(a, a + complex(2e-15, 2e-15), unitsInLastPlace = 5))
|
||||
|
||||
|
||||
let
|
||||
i64: Complex32 = complex(0.0f, 1.0f)
|
||||
|
||||
Reference in New Issue
Block a user