Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/decimal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
Base.isfinite(x::Decimal) = true
Base.isnan(x::Decimal) = false

if VERSION ≥ v"1.13"
Base.ispositive(x::Decimal) = !x.s && !iszero(x.c)
Base.isnegative(x::Decimal) = x.s && !iszero(x.c)

Check warning on line 24 in src/decimal.jl

View check run for this annotation

Codecov / codecov/patch

src/decimal.jl#L23-L24

Added lines #L23 - L24 were not covered by tests
end

"""
normalize(x::Decimal)

Expand Down
10 changes: 10 additions & 0 deletions test/test_decimal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ end

@test isfinite(Decimal(0, 1, 1))
@test !isnan(Decimal(0, 1, 1))

if VERSION ≥ v"1.13"
@test ispositive(Decimal(0, 1, 0))
@test !ispositive(Decimal(0, 0, 1))
@test !ispositive(Decimal(1, 1, 0))

@test isnegative(Decimal(1, 1, 0))
@test !isnegative(Decimal(0, 0, 1))
@test !isnegative(Decimal(0, 1, 0))
end
end

@testset "Normalize" begin
Expand Down
Loading