Metamath Proof Explorer


Theorem blennn

Description: The binary length of a positive integer. (Contributed by AV, 21-May-2020)

Ref Expression
Assertion blennn ( 𝑁 ∈ ℕ → ( #b𝑁 ) = ( ( ⌊ ‘ ( 2 logb 𝑁 ) ) + 1 ) )

Proof

Step Hyp Ref Expression
1 nnne0 ( 𝑁 ∈ ℕ → 𝑁 ≠ 0 )
2 blenn0 ( ( 𝑁 ∈ ℕ ∧ 𝑁 ≠ 0 ) → ( #b𝑁 ) = ( ( ⌊ ‘ ( 2 logb ( abs ‘ 𝑁 ) ) ) + 1 ) )
3 1 2 mpdan ( 𝑁 ∈ ℕ → ( #b𝑁 ) = ( ( ⌊ ‘ ( 2 logb ( abs ‘ 𝑁 ) ) ) + 1 ) )
4 nnre ( 𝑁 ∈ ℕ → 𝑁 ∈ ℝ )
5 nnnn0 ( 𝑁 ∈ ℕ → 𝑁 ∈ ℕ0 )
6 5 nn0ge0d ( 𝑁 ∈ ℕ → 0 ≤ 𝑁 )
7 4 6 absidd ( 𝑁 ∈ ℕ → ( abs ‘ 𝑁 ) = 𝑁 )
8 7 oveq2d ( 𝑁 ∈ ℕ → ( 2 logb ( abs ‘ 𝑁 ) ) = ( 2 logb 𝑁 ) )
9 8 fveq2d ( 𝑁 ∈ ℕ → ( ⌊ ‘ ( 2 logb ( abs ‘ 𝑁 ) ) ) = ( ⌊ ‘ ( 2 logb 𝑁 ) ) )
10 9 oveq1d ( 𝑁 ∈ ℕ → ( ( ⌊ ‘ ( 2 logb ( abs ‘ 𝑁 ) ) ) + 1 ) = ( ( ⌊ ‘ ( 2 logb 𝑁 ) ) + 1 ) )
11 3 10 eqtrd ( 𝑁 ∈ ℕ → ( #b𝑁 ) = ( ( ⌊ ‘ ( 2 logb 𝑁 ) ) + 1 ) )