Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #72 from milankl/mk/comparisons
>,<,>=,<= via signed(::Posit)
- Loading branch information
Showing
5 changed files
with
65 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,26 @@ | ||
/deps/* | ||
.DS_Store | ||
|
||
# Files generated by invoking Julia with --code-coverage | ||
*.jl.cov | ||
*.jl.*.cov | ||
|
||
# Files generated by invoking Julia with --track-allocation | ||
*.jl.mem | ||
|
||
# System-specific files and directories generated by the BinaryProvider and BinDeps packages | ||
# They contain absolute paths specific to the host computer, and so should not be committed | ||
deps/deps.jl | ||
deps/build.log | ||
deps/downloads/ | ||
deps/usr/ | ||
deps/src/ | ||
|
||
# Build artifacts for creating documentation generated by the Documenter package | ||
docs/build/ | ||
docs/site/ | ||
|
||
# File generated by Pkg, the package manager, based on a corresponding Project.toml | ||
# It records a fixed state of all packages used by the project. As such, it should not be | ||
# committed for packages, but should be committed for applications that require a static | ||
# environment. | ||
Manifest.toml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,40 @@ | ||
@testset "Comparison" begin | ||
f0,f1,f2,f3 = -0.9,-1.0,0.0,1.0 | ||
n = 100 | ||
fs = randn(n) | ||
sort!(fs) | ||
|
||
@testset for T in (Posit8, Posit16, Posit16_1, Posit32) | ||
@test (f0 > f1) == (T(f0) > T(f1)) | ||
@test (f2 >= f2) == (T(f2) >= T(f2)) | ||
@test (f3 < f1) == (T(f3) < T(f3)) | ||
@test T(f0) === T(f0) | ||
for i in 1:n-1 | ||
f1 = T(fs[i]) | ||
f2 = T(fs[i+1]) | ||
|
||
f1 == f2 || @test f2 > f1 # only test when not equal | ||
@test f2 >= f1 | ||
|
||
f1 == f2 || @test f1 < f2 # only test when not equal | ||
@test f1 <= f1 | ||
end | ||
end | ||
|
||
fs = 10*rand(n) | ||
@testset for T in (Posit8, Posit16, Posit16_1, Posit32) | ||
for f in fs | ||
p = T(f) | ||
@test p > 0 | ||
@test p >= 0 | ||
@test -p < 0 | ||
@test -p <= 0 | ||
end | ||
end | ||
|
||
# NaR is the smaller than -maxpos for comparisons | ||
@testset for T in (Posit8, Posit16, Posit16_1, Posit32) | ||
@test floatmax(T) > notareal(T) | ||
@test one(T) > notareal(T) | ||
@test floatmin(T) > notareal(T) | ||
@test zero(T) > notareal(T) | ||
@test -floatmin(T) > notareal(T) | ||
@test -one(T) > notareal(T) | ||
@test -floatmax(T) > notareal(T) | ||
end | ||
end |
73d44d7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register
73d44d7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/69291
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: