Skip to content

Commit

Permalink
Remove Base.big(obj::GapObj)
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Dec 2, 2021
1 parent c6ad566 commit 2a4c162
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 52 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Version 0.7.3-DEV (released 2021-XYZ)

- Remove `Base.big(obj::GapObj)`: nothing was using it and it does not really
fit conceptually into this package.


## Version 0.7.2 (released 2021-11-17)

- Use a `GAP_pkg_juliainterface_jll` to installed a compiled version of the
Expand Down
1 change: 0 additions & 1 deletion docs/src/conversion.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ Int128
BigInt
Rational
Float64
big
Char
Cuchar
String
Expand Down
40 changes: 0 additions & 40 deletions src/constructors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,46 +77,6 @@ julia> Int128(val)
```
""" Int128


"""
big(obj::GapObj)
Return the big integer converted from
the [GAP integer](GAP_ref(ref:Integers)) `obj`,
or the big rational converted from
the [GAP rational](GAP_ref(ref:Rationals)) `obj`,
or the big float converted from
the [GAP float](GAP_ref(ref:Floats)) `obj`.
# Examples
```jldoctest
julia> val = GAP.evalstr("2^64")
GAP: 18446744073709551616
julia> big(val)
18446744073709551616
julia> val = GAP.evalstr("1/3")
GAP: 1/3
julia> big(val)
1//3
julia> val = GAP.evalstr("1.1")
GAP: 1.1
julia> big(val)
1.100000000000000088817841970012523233890533447265625
```
"""
function Base.big(obj::GapObj)
GAP_IS_INT(obj) && return BigInt(obj)
GAP_IS_RAT(obj) && return Rational{BigInt}(obj)
GAP_IS_MACFLOAT(obj) && return BigFloat(obj)
throw(ConversionError(obj, "a type supported by big"))
end

"""
Rational{T}(obj::GapObj) where {T<:Integer}
Expand Down
11 changes: 0 additions & 11 deletions test/constructors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,6 @@
@test_throws GAP.ConversionError Float64(x)
end

@testset "big (is not a constructor but fits here)" begin
x = GAP.evalstr("2^100")
@test big(x) == BigInt(2)^100
x = GAP.evalstr("2^100/3")
@test big(x) == BigInt(2)^100 // 3
x = GAP.evalstr("2.")
@test big(x) == BigFloat(2.0)
x = GAP.evalstr("[]")
@test_throws GAP.ConversionError big(x)
end

@testset "Chars" begin
x = GAP.evalstr("'x'")
@test Cuchar(x) == Cuchar('x')
Expand Down

0 comments on commit 2a4c162

Please sign in to comment.