Definitions of floor of and ceiling

⌊x⌋ = max{n ∈ ℤ | x ≥ n}

⌈x⌉ = min{n ∈ ℤ | x ≤ n}

where ℤ is the set of all integers.

Examples

⌊3⌋=3
⌊3.14⌋=3
⌊-3.14⌋=-4

⌈3⌉=3
⌈3.14⌉=4
⌈-3.14⌉=-3

⌊3⌋

⌊3.14⌋

⌊-3.14⌋

⌈3⌉

⌈3.14⌉

⌈-3.14⌉

Plot[Tooltip[{⌊x⌋, x , ⌈x⌉}],{x, -5, 5}]

⌊x⌋ ≤  x  ≤  ⌈x⌉

(∀n ∈ ℤ)(x ≤ n \[Implies] ⌈x ⌉≤ n)

(∀n ∈ ℤ)(x ≥ n \[Implies] ⌊x⌋ ≥ n)

Relation between ⌊x⌋and⌈x⌉:

⌊x⌋=-⌈-x⌉

⌈x⌉=-⌊-x⌋

Exercise: Prove it!

(2^(⌈Log2[n]⌉)) = min{(2^k) |k∈ℕ & n ≤ (2^k)}

where ℕ is the set {0,1,2,...}of all natural numbers.

Proof.

⌈x⌉ = min{k ∈ ℤ | x ≤ k}

(2^(⌈x⌉))=(2^(min{k ∈ ℤ | x ≤ k}))=
[since (2^\[Placeholder]) is a growing function]
=min{(2^k)|k ∈ ℤ & (2^x) ≤ (2^k)}

Putting x = Log2[n] we get

(2^(⌈Log2[n]⌉))=min{(2^k)|k ∈ ℤ & (2^(Log2[n])) ≤ (2^k)}=
min{(2^k)|k ∈ ℤ & n ≤ (2^k)} =[since n>0]
 min{(2^k)|k ∈ ℕ & n ≤ (2^k)}                              □

n ≤ (2^(⌈Log2[n]⌉)) < 2n

Exercise: Prove it!

Plot[Tooltip[{n, (2^(⌈Log2[n]⌉)), 2n }],{n, 1, 100}]

(2^(⌊Log2[n]⌋)) = max{(2^k) | k∈ℕ & n ≥ (2^k)}

Exercise: Prove it!

(n/2) < (2^(⌊Log2[n]⌋)) ≤ n

Plot[Tooltip[{(n/2), (2^(⌊Log2[n]⌋)), n }],{n, 1, 100}]

The number of bits necessary to represent a positive integer n is

⌊Log2[n]⌋+1

Examples

12 = 1100 (in binary, 4 bits)

⌊Log2[12]⌋+1

1234567891=1001001100101100000001011010011
(in binary, 31 bits)

⌊Log2[1234567891]⌋+1

⌊Log2[n]⌋+1=⌈Log2[n+1]⌉

Proof in the next file.