ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Common Board

what's the meaning of k-based number?
Posted by tony002 1 Aug 2004 19:39
I don't know what's the meaning of k-based number?
Re: what's the meaning of k-based number?
Posted by Alexander Shulgin 2 Aug 2004 16:02
Hello, Tony!

`The k-based number' means a representation of a number using `k' different digits (from `0' to `k-1').
For instance:
binary numbers are 2-based -- they consist of `0' and `1'. So, `101' is 2-based representation of decimal number `5'.
More generally: any number can be represented using formula:
x = a[n] * k^n + a[n-1] * k^(n-1) + ... + a[1] * k + a[0], where a[i] is the i-th digit of number `x' in k-based system: 0 <= a[i] < k; `k' is the base of the system.

5 = 1 * 2^2 + 0 * 2 + 1 (= 4 + 0 + 1), thus binary for `5' is `101'

or

255 = 3 * 8^2 + 7 * 8 + 7 (= 192 + 56 + 7), thus octal for `255' is `377'

and, surely,

15 = 1 * 10 + 5 (= 10 + 5), thus decimal for `15' is `15' :)

Alex

PS: if something is unclear, post further messages or email me: alexander.shulgin@yessoftware.com