# Questions tagged [base-conversion]

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

149 questions
Filter by
Sorted by
Tagged with
260 views

### Converting rational numbers to an “alien” data format

For a story I'm writing, I needed to convert 101⅐ (101 + 1/7 if that doesn’t show up for you) into base 47. Expressing an integer in some base brings back memories of first learning how to program ...
426 views

### Numbers that are palindromes in N bases

Given an non-negative integer n >= 0, output forever the sequence of integers x_i >= 3 that are palindromes in exactly <...
183 views

### Mr Seckington weights his ternᵃʳʸ [duplicate]

Mr Seckington is a mobile grocer. He drives his van door-to-door selling his produce all around the nearby villages. Mr Seckington needs a method to weigh the produce he is selling so he knows how ...
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 ...
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 ...
638 views

### The beautiful pattern drawer (Little cubes included)

The beautiful pattern drawer Good morning PPCG ! The other day, when I was trying to help someone on Stack Overflow, a part of his problem gave me an idea for this challenge. First of all, check ...
292 views

### Negative XOR primes

About a year ago you were asked to find the XOR primes. These are numbers whose only factors are 1 and themselves when performing XOR multiplication in base 2. Now were are going to spice things up ...
276 views

### Convert between balanced bases!

Balanced bases: Balanced bases are essentially the same as normal bases, except that digits can be positive or negative, while in normal bases digits can only be positive. From here on, balanced ...
1k views

### Output N in base -10

Challenge: In the programming language of your choice, accept an integer as input in base 10, and output it in the negadecimal notation, which is also known as base -10 Example algorithm: This is ...
5k 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: ...
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 ...
697 views

### Count the characters - bit by bit!

The simple part: Given an input string containing only printable ASCII-characters (space - tilde), count the number of occurrences of each character and return the result on any convenient format. The ...
725 views

### Sloping Binary Numbers

Given an integer n, output the first n sloping binary numbers, either 0- or 1-indexed. They are called this because of how they ...
1k views

### The Baum-Sweet Sequence

The Baum-Sweet Sequence (A086747 with a Twist) Take in a positive integer n and print the integers from 1 to n for which the Baum-Sweet sequence returns true. The ...
292 views

### The Professor's base building number converter

The nutty maths professor wants to encode all of their research using a system sure to fox even the wiliest of their competitors! To this end the professor has decided to change the base of not just ...
201 views

### The Primitive and Basic Numbers

Your task is to generate the "Primitive and Basic" numbers, which are made like so: Start with 110. Take the digits of its base-1 representation (110 = 11) and interpret them as base-2 digits. This ...
441 views

### Sum digits till Square

Given is any integer x > 0 and any base y > 3. Sum all digits of x (if written in the set base). Multiply this by the highest possible digit (is always base -1). ...
6k 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 ...
817 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, ...
1k views

### Find the Emirps!

An emirp is a non-palindromic prime which, when reversed, is also prime. The list of base 10 emirps can be found on OEIS. The first six 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: ...
1k views

### Digital Diversity

A positive integer may be represented in an integer base 1 <= b < inf. When converted to that base it has some number of distinct digits. Any positive ...
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 ...
1k views

### The Base in the mix

Input: A list/array of integers for which each item is in the range of 2-36. Output: The sum of the integers (as base 10), where each next integer is in the base ...
732 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 ...
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 ...
196 views

### Convert to and from signed octal [closed]

Write some code to do the following: Take as its input a signed integer in either signed decimal or signed octal (explained below) If the number is decimal convert it to octal. If it's octal, convert ...
840 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 <...
786 views

### ASCII Art Mayan Numerals

This challenge is simple. Given a number, output a ascii-art representation of the number, using the Mayan Base-20 numeral system. What is the Mayan system? The Mayans used base 20 to store numbers,...
110 views

### Negative base conversion [duplicate]

We already have a base conversion question, but not one with negative bases (nope, this doesn't count). (Corresponding wiki article.) You will receive a number (may be negative) and a base (must be ...
1k views

### Is it really a comcoin?

Very interesting background Comcoins are a currency like any other. The residents of Multibaseania (an economically robust system of city-states with very few residents in a galaxy far, far away) use ...
2k views

### Primes in Different Bases

Challenge: You are given a base 10 number. For each base from 10 counting down to base 2: Take the original input number as a base 10 string, and remove any digits of the number which are invalid ...
584 views

### Write a program that converts unary input to binary, decimal, and hexadecimal equivalents

Write a program that accepts input (through stdin) as a string of unary numbers delimited by spaces, and prints the equivalent string of numbers in binary, decimal, and hexadecimal. These unary ...
74 views

### Convert a base-10 number into a number of any other base [duplicate]

You have to take a base-10 number (e.g. 735) and another number for the base to convert to, and convert the base-10 number into the equivalent number in the other base. Rules: You aren't allowed to ...
3k views

### X+Y=Z - but in which base?

The Challenge Given 3 numbers X, Y and Z in base B, ...
1k views

### Repdigit Base Finding

A repdigit is a natural number that can be written solely by repeating the same digit. For example, 777 is a repdigit, since it's solely composed of the digit ...
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 ...
885 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:...
1k views

### Octal, Decimal, or Hexadecimal?

Given an input string containing only letters and numbers, write a program or function that prints the possible printable ASCII characters (Hex 20-7E) that correspond with the string's value in bases ...
295 views

### Convert a “mixed-base” string to ASCII

Given an input of a string with bytes that may be in either binary, octal, or hex, output the string's ASCII equivalent. Input will be provided in the following format, for example: ...
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 ...
223 views

### “Fouriest” Transform of An Integer [duplicate]

Challenge Inspired by this SMBC comic, discussed on reddit, math.stackexchange, and calculus7, the challenge is to return the lowest base such that a number is "fouriest." Description [From the ...
765 views

### Fibonacci’s sexagesimals

Leonardo da Pisano a.k.a Fibonacci was instrumental in bringing the Hindu-Arabic numeral system into Europe. Before that, mathematicians there worked in base sixty with Roman numerals. For example, ...
280 views

### Find the nth base-b digit of (b^k-1)^-2

Task Your task is simple. Write a program or function which takes three positive integer arguments n, k, and b in any order, such that 2 ≤ b ≤ 36, and returns or outputs the nth (1-indexed) base-b ...
1k views

### Zeroes in interval

Your task is to write a function or program that takes two non-negative integers i and k (i ≤...
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 ...
240 views

### Look and Say sequence in any base

We all already crossed the look and say sequence, and where asked to guess the next element. As its name tells it very well, you just have to say what you see : ...
988 views

### Base Conversion With Strings

Introduction We've have a few base conversion challenges here in the past, but not many designed to tackle arbitrary length numbers (that is to say, numbers that are long enough that they overflow ...