Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Unary coding
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Generalized unary coding== A generalized version of unary coding was presented by [[Subhash Kak]] to represent numbers much more efficiently than standard unary coding.<ref name="Kak_2015"/> Here's an example of generalized unary coding for integers from 0 through 15 that requires only 7 bits (where three bits are arbitrarily chosen in place of a single one in standard unary to show the number). Note that the representation is cyclic where one uses markers to represent higher integers in higher cycles. {| class="wikitable" ! n !! Unary code !! Generalized unary |- | 0 || 0 || 0000000 |- | 1 || 10 || 0000111 |- | 2 || 110 || 0001110 |- | 3 || 1110 || 0011100 |- | 4 || 11110 || 0111000 |- | 5 || 111110 || 1110000 |- | 6 || 1111110 || 0010111 |- | 7 || 11111110 || 0101110 |- | 8 || 111111110 || 1011100 |- | 9 || 1111111110 || 0111001 |- | 10 || 11111111110 || 1110010 |- | 11 || 111111111110 || 0100111 |- | 12 || 1111111111110 || 1001110 |- | 13 || 11111111111110 || 0011101 |- | 14 || 111111111111110 || 0111010 |- | 15 || 1111111111111110 || 1110100 |} Generalized unary coding requires that the range of numbers to be represented to be pre-specified because this range determines the number of bits that are needed.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)