Skip to content

Commit 33c2ba6

Browse files
committed
Deprecate bits to bitstring.
1 parent 175f7a1 commit 33c2ba6

8 files changed

+35
-31
lines changed

NEWS.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -556,8 +556,9 @@ Deprecated or removed
556556
`ReinterpretArray`. The three argument form of `reinterpret` that implicitly reshapes
557557
has been deprecated ([#23750]).
558558

559-
* `num2hex` and `hex2num` have been deprecated in favor of `reinterpret` combined with `parse`/`hex`
560-
([#22088])
559+
* `bits` has been deprecated in favor of `bitstring` ([#WHATAREBIRDS]).
560+
561+
* `num2hex` and `hex2num` have been deprecated in favor of `reinterpret` combined with `parse`/`hex` ([#22088]).
561562

562563

563564
Command-line option changes

base/deprecated.jl

+3
Original file line numberDiff line numberDiff line change
@@ -1913,6 +1913,9 @@ end
19131913
@deprecate float(x::AbstractString) parse(Float64, x)
19141914
@deprecate float(a::AbstractArray{<:AbstractString}) parse.(Float64, a)
19151915

1916+
# deprecate bits to bitstring
1917+
@deprecate bits(x) bitstring(x)
1918+
19161919
# issue #24167
19171920
@deprecate EnvHash EnvDict
19181921

base/exports.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ export
722722
Base64DecodePipe,
723723
startswith,
724724
bin,
725-
bits,
725+
bitstring,
726726
bytes2hex,
727727
chomp,
728728
chop,

base/intfuncs.jl

+9-9
Original file line numberDiff line numberDiff line change
@@ -708,26 +708,26 @@ julia> dec(20, 3)
708708
dec
709709

710710
"""
711-
bits(n)
711+
bitstring(n)
712712
713713
A string giving the literal bit representation of a number.
714714
715715
# Examples
716716
```jldoctest
717-
julia> bits(4)
717+
julia> bitstring(4)
718718
"0000000000000000000000000000000000000000000000000000000000000100"
719719
720-
julia> bits(2.2)
720+
julia> bitstring(2.2)
721721
"0100000000000001100110011001100110011001100110011001100110011010"
722722
```
723723
"""
724-
function bits end
724+
function bitstring end
725725

726-
bits(x::Union{Bool,Int8,UInt8}) = bin(reinterpret(UInt8,x),8)
727-
bits(x::Union{Int16,UInt16,Float16}) = bin(reinterpret(UInt16,x),16)
728-
bits(x::Union{Char,Int32,UInt32,Float32}) = bin(reinterpret(UInt32,x),32)
729-
bits(x::Union{Int64,UInt64,Float64}) = bin(reinterpret(UInt64,x),64)
730-
bits(x::Union{Int128,UInt128}) = bin(reinterpret(UInt128,x),128)
726+
bitstring(x::Union{Bool,Int8,UInt8}) = bin(reinterpret(UInt8,x),8)
727+
bitstring(x::Union{Int16,UInt16,Float16}) = bin(reinterpret(UInt16,x),16)
728+
bitstring(x::Union{Char,Int32,UInt32,Float32}) = bin(reinterpret(UInt32,x),32)
729+
bitstring(x::Union{Int64,UInt64,Float64}) = bin(reinterpret(UInt64,x),64)
730+
bitstring(x::Union{Int128,UInt128}) = bin(reinterpret(UInt128,x),128)
731731

732732
"""
733733
digits([T<:Integer], n::Integer, base::T=10, pad::Integer=1)

base/operators.jl

+8-8
Original file line numberDiff line numberDiff line change
@@ -518,10 +518,10 @@ this is equivalent to `x >> -n`.
518518
julia> Int8(3) << 2
519519
12
520520
521-
julia> bits(Int8(3))
521+
julia> bitstring(Int8(3))
522522
"00000011"
523523
524-
julia> bits(Int8(12))
524+
julia> bitstring(Int8(12))
525525
"00001100"
526526
```
527527
See also [`>>`](@ref), [`>>>`](@ref).
@@ -548,19 +548,19 @@ right by `n` bits, where `n >= 0`, filling with `0`s if `x >= 0`, `1`s if `x <
548548
julia> Int8(13) >> 2
549549
3
550550
551-
julia> bits(Int8(13))
551+
julia> bitstring(Int8(13))
552552
"00001101"
553553
554-
julia> bits(Int8(3))
554+
julia> bitstring(Int8(3))
555555
"00000011"
556556
557557
julia> Int8(-14) >> 2
558558
-4
559559
560-
julia> bits(Int8(-14))
560+
julia> bitstring(Int8(-14))
561561
"11110010"
562562
563-
julia> bits(Int8(-4))
563+
julia> bitstring(Int8(-4))
564564
"11111100"
565565
```
566566
See also [`>>>`](@ref), [`<<`](@ref).
@@ -589,10 +589,10 @@ For [`Unsigned`](@ref) integer types, this is equivalent to [`>>`](@ref). For
589589
julia> Int8(-14) >>> 2
590590
60
591591
592-
julia> bits(Int8(-14))
592+
julia> bitstring(Int8(-14))
593593
"11110010"
594594
595-
julia> bits(Int8(60))
595+
julia> bitstring(Int8(60))
596596
"00111100"
597597
```
598598

doc/src/manual/integers-and-floating-point-numbers.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -311,10 +311,10 @@ can be seen using the `bits` function: :
311311
julia> 0.0 == -0.0
312312
true
313313
314-
julia> bits(0.0)
314+
julia> bitstring(0.0)
315315
"0000000000000000000000000000000000000000000000000000000000000000"
316316
317-
julia> bits(-0.0)
317+
julia> bitstring(-0.0)
318318
"1000000000000000000000000000000000000000000000000000000000000000"
319319
```
320320

@@ -443,13 +443,13 @@ julia> nextfloat(x)
443443
julia> prevfloat(x)
444444
1.2499999f0
445445
446-
julia> bits(prevfloat(x))
446+
julia> bitstring(prevfloat(x))
447447
"00111111100111111111111111111111"
448448
449-
julia> bits(x)
449+
julia> bitstring(x)
450450
"00111111101000000000000000000000"
451451
452-
julia> bits(nextfloat(x))
452+
julia> bitstring(nextfloat(x))
453453
"00111111101000000000000000000001"
454454
```
455455

test/intfuncs.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,11 @@ end
133133

134134
@test base(2, 5, 7) == "0000101"
135135

136-
@test bits(Int16(3)) == "0000000000000011"
137-
@test bits('3') == "00000000000000000000000000110011"
138-
@test bits(1035) == (Int == Int32 ? "00000000000000000000010000001011" :
136+
@test bitstring(Int16(3)) == "0000000000000011"
137+
@test bitstring('3') == "00000000000000000000000000110011"
138+
@test bitstring(1035) == (Int == Int32 ? "00000000000000000000010000001011" :
139139
"0000000000000000000000000000000000000000000000000000010000001011")
140-
@test bits(Int128(3)) == "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011"
140+
@test bitstring(Int128(3)) == "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011"
141141
end
142142
@testset "digits/base" begin
143143
@test digits(4, 2) == [0, 0, 1]

test/numbers.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -2369,8 +2369,8 @@ end
23692369
@test -0.0 + false === -0.0
23702370

23712371
@testset "issue #5881" begin
2372-
@test bits(true) == "00000001"
2373-
@test bits(false) == "00000000"
2372+
@test bitstring(true) == "00000001"
2373+
@test bitstring(false) == "00000000"
23742374
end
23752375
@testset "edge cases of intrinsics" begin
23762376
let g() = sqrt(-1.0)

0 commit comments

Comments
 (0)