Share Your Experience: Take the 2024 Developer Survey

# Questions tagged [base-conversion]

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

188 questions
Filter by
Sorted by
Tagged with
286 views

### Where are zeros? Self-describing sequence

Background A167519: Lexicographically earliest increasing sequence which lists the positions of the zero digits in the sequence. ...
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 ...
2k views

### Sum of Binary Substrings

This challenge is simple, given a decimal number, convert to binary, and calculate the sum of the sub-strings of the binary number, whose length is shorter than the original number. Here is an example:...
4k views

### 16-bit binary grid

Given any unsigned 16 bit integer, convert its decimal form (i.e., base-10) number into a 4x4 ASCII grid of its bits, with the most-significant bit (MSB) at the top left, least-significant bit (LSB) ...
3k views

### Simplify binary

Challenge Given a binary number as input through any means, "simplify" the number using a full program or a function. Input [binary] ...
2k views

Convert a hexadecimal number (of any size) into a binary number. Input A POSITIVE hexadecimal number with a 0x in the beginning. A valid input will always match the ...
5k views

### Numbers that are actually letters

Given a non-negative integer input, write a program that converts the number to hexadecimal and returns a truthy value if the hexadecimal form of the number contains only the characters ...
4k views

### Increment base-36 strings

This is a code golf version of a similar question I asked on stack earlier but thought it'd be an interesting puzzle. Given a string of length 10 which represents a base 36 number, increment it by one ...
1k views

### All your base palindromic belong to us

Generate the sequence number of bases in which n is a palindrome (OEIS A126071). Specifically, the sequence is defined as follows: given a number ...
1k views

### Non-palindromic numbers

A strictly non-palindromic number N is a number that isn't a palindrome in any base (in bases 2 to N-2). These numbers are listed on OEIS For example, the number 19...
218 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 ...
292 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 ...
152 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$ ...
1k views

### Possible binaries sum

This challenge is inspired by the AoC 2020, Day 14 - Part II, created by Eric Wastl and his team, which asks to output the possible binary values from a bitmask. Let's say we've a bitmask like ...
1k views

### Compute the Redwolf Checksum™ of some data

I will preface this by saying that I made this for fun; I have absolutely no formal knowledge on cryptography or error correction. Do not use this algorithm in anything remotely important. I was kind ...
997 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 ...
9k views

### Convert RGB integer value into RGB values

For example, in traditional web hexadecimal, a certain base-16 number represents an RGB value. For example, 45A19C equals (69,161,156) in RGB. You'll be converting from that number to RGB value, ...
2k views

### Minimum base to count to a string

The Challenge Input: alphanumeric string. You can assume that the string will only contain the characters [0-9A-Z]. This can come from a parameter, command line, or STDIN. Digits are always before ...
2k views

### Reverse and square

In this challenge you will compute numbers from a curious sequence. Your input is a single decimal nonnegative integer. Reverse the bits in this integer and then square the number to get the required ...
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$ ...
6k views

### What base is this number in?

Here's a nice easy challenge: Given a string that represents a number in an unknown base, determine the lowest possible base that number might be in. The string will only contain ...
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 ...
2k views

### Brainf**k to Unary and Back

A language that is very useful in restricted source and other such challenges is Unary, a brainfuck derivative in which programs are written in with only one character. Your job is to write a program ...
2k views

### Tic Tac Toe encoder/decoder

James Bond is about to start a new mission and you are his computer scientist friend. As Tic Tac Toe is becoming more and more popular you decide that nothing would be more underhanded than a Tic Tac ...
7k views

### Convert a 32 bit binary IPv4 address to its quad-dotted notation

Challenge Write a program or function that converts a 32 bit binary number to its quad-dotted decimal notation (often used for representing IPv4) Quad-dotted decimal A quad-dotted decimal is formed ...
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...
9k views

### Balanced Ternary Converter

Credits for the challenge idea go to @AndrewPiliser. His original proposal in the sandbox was abandoned and since he has not been active here for several months, I have taken over the challenge. ...
3k views

### Up go the bits!

Given an integer N perform the following steps: (using 9 as an example). Receive input N. (9) Convert N from base10 to base2. (...
10k views

### What is the reverse (binary) bit number?

So you are given a POSITIVE base 10 (decimal) number. Your job is to reverse the binary digits and return that base 10 number. Examples: ...
9k views

### Binary to decimal converter

Binary to decimal converter As far as I can see, we don't have a simple binary to decimal conversion challenge. Write a program or function that takes a positive binary integer and outputs its ...
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 (&...
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 ...
1k views

### Determine if an integer is a palindrome in a given radix (base)

Write a program that reads from stdin two integers, each newline terminated, hereafter called "number" and "radix", and: Prints any fixed message you want if the number is a palindrome in that radix (...
747 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, ...
1k views

### Find the longest rep digit

Your task is to take a positive number as input, n, and output the length of the longest rep-digit representation of n in any base. For example 7 can be represented as any of the following ...
4k views

### Smallest Zeroless Base

Given a positive integer n, output the smallest base b >= 2 where the representation of n ...
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 ...
620 views

### Find how "smooth" a number is based on binary

I haven't been on PP&CG for a while, so I thought I would post something! Your task is to find how "smooth" a natural number is. Your method is to: 1: Convert the number to binary 2: Find the ...
1k views

### All the Xenodromes

Introduction A xenodrome in base n is an integer where all of its digits in base n are different. Here are some OEIS sequences of xenodromes. For example, in base 16, ...
6k views

### The best base is 10... Let's reach it!

Input: A positive integer n consisting of digits in the range 0-9. Challenge: If d is the highest digit in the integer, assume the base of the number is d+1. E.g. if the integer is 1256 then you ...
2k views

### Decompose binary into alternating subsequences

This was inspired by Problem 13 - Non-Repeating Binary of HP CodeWars' recent competition. Let's take a random decimal number, say 727429805944311 and look at ...
2k views

### Calculate the binary split sum of a word

Take a string, s containing printable ASCII-characters as input, and output its "binary split sum". Need an explanation? How do you get the binary split sum? We'...
3k views

### Base85 Encoding

The Challenge Write a program that can take an input of a single-line string containing any ASCII printable characters, and output the same string encoded in Base85 (using a big-endian convention). ...
4k views

1k views

### Decompose a number!

Your task is to decompose a number using the format below. This is similar to base conversion, except that instead of listing the digits in the base, you list the <...
2k views

### A multiplication table for the Cheela

The Cheela (from the book Dragon's Egg by Robert L. Forward) are creatures that live on the surface of a neutron star. Their body is flat and circular with twelve eyes on the perimeter, so they ...