Skip to content

Commit 78f55de

Browse files
authored
add (un)signed(::Type{Bool}) method (#35854)
1 parent dd04e92 commit 78f55de

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

base/int.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ julia> signed(UInt64)
7070
Int64
7171
```
7272
"""
73+
signed(::Type{Bool}) = Int
7374
signed(::Type{UInt8}) = Int8
7475
signed(::Type{UInt16}) = Int16
7576
signed(::Type{UInt32}) = Int32

base/multinverses.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Base: div, divrem, rem, unsigned
66
using Base: IndexLinear, IndexCartesian, tail
77
export multiplicativeinverse
88

9+
unsigned(::Type{Bool}) = UInt
910
unsigned(::Type{Int8}) = UInt8
1011
unsigned(::Type{Int16}) = UInt16
1112
unsigned(::Type{Int32}) = UInt32

test/int.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ end
6363
@test signed(true) == 1
6464
@test unsigned(true) isa Unsigned
6565
@test unsigned(true) == unsigned(1)
66+
67+
@test signed(Bool) == Int
68+
@test signed(Bool) == typeof(signed(true))
69+
@test unsigned(Bool) == UInt
70+
@test unsigned(Bool) == typeof(unsigned(true))
6671
end
6772
@testset "bswap" begin
6873
@test bswap(Int8(3)) == 3

0 commit comments

Comments
 (0)