The 2024 Developer Survey results are live! See the results

# Questions tagged [base-conversion]

Conversion of numbers between positional numeral systems. Most common systems are decimal, binary, hexadecimal etc.

191 questions
Filter by
Sorted by
Tagged with
5k 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 → ...
828 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,401
480 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-...
391 views

### Where are zeros? Self-describing sequence

Background A167519: Lexicographically earliest increasing sequence which lists the positions of the zero digits in the sequence. ...
• 78.1k
231 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 ...
• 1,073
310 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 ...
• 10.6k
156 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$ ...
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 ...
• 8,752
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...
• 6,035
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 (&...
• 7,908
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 ...
• 571
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, ...
• 78.1k
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 ...
• 499
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 ...
• 16.7k
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 ...
• 1,357
3k views

• 24k
1k views

### Bijective meets mixed base

Background A bijective base $b$ numeration, where $b$ is a positive integer, is a bijective positional notation that makes use of $b$ symbols with associated values of $1,2,\cdots,b$. ...
• 78.1k
2k views

### How long is the number in this base?

Given a positive integer $n$ and another positive integer $b$ ($1 < b < 36$), return the number of digits/length of $n$ in base $b$ ...
• 133
948 views

• 10.8k
3k views

### Convert negadecimal to decimal (and back)

Negadecimal, also known as base -10, is a non-standard positional numeral system. Take the number $1337_{10}$. In decimal, this has the value one thousand three hundred thirty seven, and can be ...
• 18.8k
2k views

### Display the exponent from a binary floating point number as a decimal value

Had my software final exams recently, one of the last questions had me thinking for a while after the exam had finished. Background IEEE754 numbers are according to the below layout The exponent is ...
735 views

• 50.1k
289 views

### Mirror, Mirror, on the wall. Who's the fairest of them all?

Well, you know it's Snow White, and the evil Queen is at it again. Will Snow White be saved? Will she fall asleep once again? Will the Prince find her? Challenge: Given an arbitrary number (>= 2) ...
• 279
9k views

Sandbox French License Plates French license plates come in a sequential order, following a specific pattern of numbers and letters : AB-012-CD Challenge Write ...
• 1,053
2k views

### Simplification of numbers

How, you can’t remember the 6 or 7-digit phone number that appeared on the TV screen for a second?! Using the special technique described below, you will turn into a walking phonebook! Obviously, the ...
• 607
575 views

### Convert alphanumeric (base-36) sentences into hexadecimal (base-16) sentences

I use "sentence" here loosely to mean "any sequence of words separated by spaces" and "words" to mean "sequences of alphanumeric (hexatrigesimal) characters unseparated by spaces". Conversion is from ...
• 640