Questions tagged [base-conversion]
Conversion of numbers between positional numeral systems. Most common systems are decimal, binary, hexadecimal etc.
191
questions
18
votes
19
answers
4k
views
Wait, ASCII was 128 characters all along?
Challenge
In this challenge, you have to take a nonnegative integer as input, convert it into base-128 bytes (0 → 0x00, 127 → ...
7
votes
7
answers
815
views
Parity of a number with missing digits
It turns out that you need every digit of a number to determine its parity, if it is written in an odd base.
Your programs should take input as a number between 2 and 36 inclusive, and a nonempty ...
-1
votes
3
answers
471
views
Sum of Positive and Negative Powers of 2
Given a binary string equivalent to \$n\$, write out the least possible number of terms needed to express \$n\$.
A term is defined as an addition of either \$2^k\$ or \$(-2^k)\$, where \$k\$ is a non-...
14
votes
2
answers
387
views
Where are zeros? Self-describing sequence
Background
A167519: Lexicographically earliest increasing sequence which lists the positions of the zero digits in the sequence.
...
4
votes
1
answer
229
views
Convert real numbers between factoradic and positive integer bases
This prompt asked you to convert back and forth to factoradic, but is very limited in scope (only decimal integers from 0 to 10!-1). Your task in this challenge is to reach just a bit further and ...
7
votes
1
answer
305
views
Literate Programming in Base 26
Your task is to convert non-empty strings - between strings using the 26 letters, and programs, which are strings of bytes, where each byte has 256 possible values. You should use the same codepage ...
4
votes
5
answers
155
views
Base consecutive k-frequency counter [closed]
Given a base \$k\$ as well as two indices (also passed in base \$k\$, call them \$s\$ and \$e\$) return a list containing a frequency count of all base-\$k\$ digits occurring between \$s\$ and \$e\$ ...
13
votes
40
answers
3k
views
Convert binary to unary
The title says it all; Given a number in the binary (base-2) number system, output the same number expressed in unary (base-1).
You should take the binary number as a string (optionally with a ...
19
votes
10
answers
3k
views
Numbers that can be negated by reading backwards
Balanced ternary is a modified version of ternary (base 3), using the three digits 1,0 and -1...
16
votes
6
answers
1k
views
Cube calendar numbers
Credit: Marco Verch CC BY 2.0
A two-cube calendar, as shown in the picture, uses two cubes with digits painted on the faces to display the date. For dates in the range 1-9, a leading zero is used (&...
11
votes
16
answers
1k
views
Multibase Numbers
(Similar: Through the bases)
Normally, our number system is base ten, with the digits 0123456789. However, we can increase or decrease the base count (so ...
15
votes
21
answers
751
views
CGAC2022 Day 16: Playing with bits, Part 2
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details.
As soon as the Elves get bored with the last week's game, Bin comes up with a new game. The rules are similar, ...
13
votes
25
answers
2k
views
Output the length of (the length plus a message) [duplicate]
The task is simple. You're given an arbitrary string message. Return that message prefixed with a number, such that the length of that number plus the message equals the number. In other words, the ...
19
votes
25
answers
2k
views
Carry-less sum given a base b
Given a list of positive integers \$\mathcal I=I_1,I_2,I_3,...,I_n\$ and a base \$b>1\$ return their "carry-less sum", i.e. represent \$\mathcal I\$ in base \$b\$ and sum digit-by-digit ...
20
votes
30
answers
3k
views
Convert from variable-width Two's Complement to Integer
Take an input, and convert it from Two's Complement notation (binary where the first bit is negated, but the rest are taken as normal) into an integer (in a somewhat standard output form). Input can ...