Questions tagged [base-conversion]

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

175 questions
Filter by
Sorted by
Tagged with
15k views

xkcd-Style Page Numbering

Randall Munroe's book "xkcd, volume 0" uses a rather odd number system for the page numbers. The first few page numbers are ...
9k views

Count down from "Infinity"

Seems like an impossible task right? Well, it's actually not that hard. If we write the word Infinity as 8-bit binary ASCII code, we'll get: ...
2k views

In this challenge, you will receive an input, convert it to hexadecimal, make a couple changes, and output the result. Because they are only 16 characters in hexadecimal, your code will need to be as ...
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 ...
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 ...
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 ...
8k 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 ...
4k views

Output numbers up to 2^n-1, "sorted"

Take a positive integer n as input, and output (some of the) decimal numbers that can be created using n bits, ordered in the following way: First list all the numbers that can be created with only ...
3k views

Mark My Mail! - ASCII Barcodes

4-state barcodes Many postal services (Royal Mail UK, Canada Post, US Mail, etc) use a 4-state barcode to encode information about their mail. Rendered in ASCII, it may look something like this: | ...
9k 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: ...
8k 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. ...
2k views

I don't like numbers, but I do like the Fibonacci sequence. I'm sure we could work something out. Please read one integer n from STDIN and output the nth Fibonacci number in base 26 (...
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) ...
4k views

Biplex: an important useless operator

Input A list of between 1 and 255 positive integers (inclusive), each in the range 1 to 232 - 1 (inclusive). Your input format does not need to be identical to the test cases. Input without leading ...
2k views

Compute the generalised XOR

The goal of this challenge is to generalise the bitwise XOR function to other bases. Given two non-negative integers $x$ and $y$, and another integer $b$ such that $b \geq 2$, write a ...
2k views

Standardise a Phinary Number

Background Most people on here should be familiar with a few integer base systems: decimal, binary, hexadecimal, octal. E.g. in the hexadecimal system, a number $abc.de_{16}$ would represent a\...
5k 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 ...
3k views

Please excuse the punny title. This is a question is inspired by A Curious Property of 82000. In it, the author points out that the number 82000 is binary in base 2, 3, 4, and 5. The post then ...
4k views

How close are we, really?

Please note: this is a restricted-source challenge — see details below! Each natural number $n$ has 10 faces: its decimal representations in bases $1$ through to $10$. For example, the 10 faces ...
2k views

Custom Number Base Converter

The powers that be want to be able to quickly convert any number they have into their own number base using any format they would like. Input Your program must accept 3 parameters. Number: The ...
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 ...
4k views

Those Greedy Romans!

Given a strictly positive integer, return the shortest possible Roman numeral using only the additive rule. Output must consist of zero or more of each of the characters ...
3k views

0xUsernames There's so many people using a messaging service that they're running out of space to store all the usernames! To fix this, they are going to start storing usernames as hexadecimal, where ...
6k views

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

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. (...
3k views

Obfuscating text by cycling ternary digits

The goal of this challenge is the write the shortest function/program to take input text, encrypt it using the method below, and return the result. As an example, I will use the string ...
4k views

Smallest Zeroless Base

Given a positive integer n, output the smallest base b >= 2 where the representation of n ...
3k views

Is this a three-digit number ending in one?

Given a nonnegative integer, return whether it is a three digit number ending in one, in any consistent integer base. In other words, the number needs to be represented in base-N, N being an integer ...
4k views

1+1 = 10, 1+2 = 3

Write a function or program than can do simple arithmetic (addition, subtraction, multiplication and division) in both base 10 and base 2. The function will take a mathematical expression as input, ...
3k views

Find the next 1-sparse binary number

A positive integer N is K-sparse if there are at least K 0s between any two consecutive 1s in its binary representation. So, the number 1010101 is 1-sparse whereas 101101 is not. Your task is to ...
1k views

Find the sum of all possible base representations

The objective of this challenge is to write a program to convert an inputed string of what can be assumed as containing only letters and numbers from as many bases between 2 and 36 as possible, and ...
10k views

Convert to and from the factorial number system

The Factorial Number System, also called factoradic, is a mixed radix numeral system. The factorials determine the place value of a number. In this system, the right most digit can be either 0 or 1, ...
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 ...
5k views

Cheating a multiple choice test, part 2

This is sequel to this challenge by Adnan. If you like this challenge, chances are you'll like the other one too. Check it out! A multiple choice test with 8 questions each with 4 choices might have ...
2k views

Not Quite Roman Ternary

Given an integer n ≥ 0 , output it in a non-positional base-3 notation, using digits 139ABCDE… and a 1-character separator. Every digit is a consecutive power of 3 ...
2k views

Residue Number System

In the vein of large number challenges I thought this one might be interesting. In this challenge, we will be using the Residue Number System (RNS) to perform addition, subtraction, and ...
2k views

Count the trailing zeros

Given two positive integers $n$ and $b$, such that $n > 2$ and $n > b > 1$, count the trailing zeros when converting $n$ to base $b$. Your program should be able to handle any ...
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 ...
1k views

Find the nth Fibohexaprime

The challenge this time is to find the nth Fibohexaprime. The definition of a Fibohexaprime is as following: We first observe a list with Fibonacci numbers: ...
2k views

All your bijective base are belong to us

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 to b. Unlike its non-bijective ...
4k views

ASCII art uncompression from a base-n number

This is inspired by an 05AB1E answer by Magic Octupus Urn. Given two arguments, a positive integer and a string/list of characters: Translate the number to base-n, where n is the length of the ...
3k views

Take a byte out of it!

Your task is to, given an unsigned integer n, find the largest number which can be created by removing a single byte (8 consecutive bits) of data. Example Given ...
2k views

Implement a Stopwatch

Implement a simple digital Stopwatch, which will display the time elapsed in seconds and minutes, as described below. Important Please read both Display and Controls sections ! Display Time elapsed, ...
1k views

Parse the Parcel

Thanks to your help in the Mark My Mail challenge, PPCG-Post has successfully stamped all of its parcels with the generated barcodes! Now, it's time to decode them. In this challenge your program ...
2k views

Determine the Base where a Given Equation is True

Given 3 integers, determine the lowest possible base for the first two integers to multiply into the third. If you think of the Answer to the Ultimate Question of Life, The Universe, and Everything, 6 ...
3k views

Challenge Here's a simple one. Write a function or program when given a number in base 10 as input, it will return or print that number's value in Hexadecimal. Examples ...
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'...
2k views

ASCII Character Jumble

Write a program that takes as its input a string consisting of printable characters (ASCII 20-7E) and an integer n in [2,16] and performs the following modification ...