Quotient and Remainder to Number Base
From ProofWiki
Contents |
[edit] Theorem
Let
be an integer.
Let
be expressed in base
:
i.e.
Then:
where:
-
denotes the floor function;
-
denotes the modulo operation.
[edit] General Result
where
.
[edit] Proof
From the Quotient-Remainder Theorem, we have:
where
.
We have that:
|
|
| ||||
|
| |||||
|
|
Hence we can express
where:
where
.
The result follows from the definition of the modulo operation.
[edit] Proof of General Result
Follows directly by induction on
.
[edit] Example
This result is often[1] used in computer algorithms for converting a date (in
format) into a date object with separate day, month and year.
Performing the above "mod and div" operations on
, we get:
|
|
| which gives us the day | |||
|
|
| which we use as input into the next pass | |||
|
|
| which gives us the month | |||
|
|
| which gives us the year. |
[edit] Notes
- ↑ So often, in some business applications, that the author of this page is utterly sick of it, truth be told.

