Questions tagged [number-systems]

Questions about representing numbers in alternative representations, such as hexadecimal or Mayan

Filter by
Sorted by
Tagged with
17
votes
1answer
23k views

Excel column string to row number and vice versa

Excel column letters to actual numbers, if you recall, Excel names its columns with letters from A to Z, and then the sequence goes AA, AB, AC... AZ, BA, BB, etc. You have to write a function that ...
12
votes
4answers
1k views

Arabic to Greek numeral converter, 1 - 10

One of the things that's straight-forward in JavaScript is Unicode support. If you want to return ϝ (lowercase digamma, not a simple ...
10
votes
3answers
972 views

Karazuba Algorithm with arbitrary bases

I'm working on an implementation of the Karazuba Algorithm. I created a class BN which represents a number in an arbitrary base (and supports elementary operations)...
9
votes
6answers
5k views

Base 26 (letters) and Base 10 using recursion

I was messing around with base conversion between decimal and Base26 (alphabet) with no 0th case because I needed it for the Google Sheets API in order to find specific cell values from a 3 ...
9
votes
1answer
7k views

Implement numbering scheme like A,B,C… AA,AB,… AAA…, similar to converting a number to radix26

I want to implement numbering scheme like Microsoft Word uses for numbering. first one gets = A,next is B, next is C, .... then AA, then AB,....and so on. as shown below ...
9
votes
4answers
386 views

Simple Number to Words using a Single Loop String Triplets in JavaScript

I have extensively reviewed 2 old articles on the subject: https://stackoverflow.com/questions/14766951/convert-digits-into-words-with-javascript and https://stackoverflow.com/questions/5529934/...
8
votes
3answers
11k views

Convert Persian and Arabic digits to English

I use the following utility method to convert Persian and Arabic digits to English using regex: ...
8
votes
5answers
399 views

Convert decimal to binary

This program converts a decimal number to a binary number. This is one of my first C programs and I am wondering if I have used the elements of this language properly. Suggestions for improvement are ...
8
votes
3answers
5k views

Convert binary string to decimal number

I'm finishing the book C Primer Plus by Stephen Prata and I wrote as a part of the homework program to convert binary string to decimal number: ...
7
votes
2answers
1k views

Binary to decimal converter

I started a few weeks ago to learn C++ online. I just made a little binary → decimal program. Here is my code: ...
7
votes
1answer
2k views

Function to convert a decimal number as a string to hexadecimal

I am designing a cipher and need to convert between bases repeatedly in a loop. I have optimized everything else, but I'm not too familiar with C++ code, and and am trying to figure out how to make ...
7
votes
4answers
1k views

Printing all binary strings of length n

I have completed my homework with directions as follows: Declare and implement a class named Binary. This class will have a method named printB(int n) that prints all binary strings of length n. ...
7
votes
1answer
8k views

Multiplying and Adding Large Numbers

Lately, I've been working on the Euler projects. I just started coding in C++ and could really use some feedback. Basically, I wrote a program to calculate the factorial of any number between 1 and ...
7
votes
3answers
5k views

Converting decimal integer to binary string

I'm wondering how I can make this function better, more compact, even faster. ...
6
votes
4answers
384 views

Interview practice: Integer to Roman

Student here. I'm practicing for coding interviews right now. In that context, how would you recommend I improve my code for this practice problem? ...
6
votes
3answers
100 views

Program that outputs binary values of input

I am looking to simplify my main() function. The nested if statements contain four lines of the same code, and I'm unsure of how to refactor and simplify it. I was attempting to use booleans, which ...
6
votes
2answers
207 views

(Almost) arbitrary base ints with decorated methods

After reading this question about returning the "next" string in some alphabet (the digits, followed by upper and lowercase ASCII letters) using Java, I thought, well that's just counting, so why not ...
6
votes
1answer
756 views

Roman Numeral class in Python

I've built a Roman numeral class in Python, and I want to know what can be improved in it. An assumption I'm making is that the initialization of an object will use valid Roman numerals (I, V, X, L, C,...
6
votes
2answers
2k views

Adding arbitrarily long integers C++ (string represented)

I'm working through some Project Euler problems using C++ and some of the numbers in question are starting to get quite large (21000 for Problem 16) and I need to add some of these large numbers ...
6
votes
2answers
4k views

Java conversion of base 16 to base 64

I wrote a solution in Java to solve the problem here. I use BigInteger to convert first from base 16 to base 10, then base 10 to base 64. This seems quite ...
6
votes
3answers
107 views

Learn You A Hex

This small program generates random operands and operations and asks the user to perform the computation and input the result. I want to make it more C++ and remove any C-ness it might inappropriately ...
6
votes
1answer
877 views

C binary number converter (Hex and Decimals)

I'm still new to C programming, but I'm playing around with it to ensure I progress. I just made the following converter that takes 8 numbers (0 and 1) as binary code then converts the binary value to ...
5
votes
4answers
19k views

Hex to Decimal converter

Any feedback is welcome: ...
5
votes
4answers
125 views

Java code to convert between hex & binary strings

I have two methods in my code which are using the majority of the CPU time that convert between binary and hex strings and the reverse. I use a static lookup map to convert the individual characters ...
5
votes
3answers
752 views

Hex dump of a list of 16-bit numbers

This is some code which prints a hexdump of a list of 16 bit numbers, at 16 bytes distance for each, after the "print data" comment: ...
5
votes
2answers
206 views

String to binary converter

I did research about binary counting, and wanted to make an application in Java that converts a string to binary code: ...
5
votes
3answers
4k views

Decimal/binary/hex converter

I've finally finished my converter and have determined that it works, but I'm trying to make it cleaner and/or more practical (primarily with the switch statements)....
5
votes
1answer
117 views

Base-changing numbers in Java

On a whim, I came up with this program to act as a helper class for base changing, if I require it in the future. It was made to support fixed-point and negative inputs, but they are basically a hack. ...
5
votes
1answer
339 views

Swift function to interpret Roman numerals (ported from JavaScript)

I have written some Swift for the first time, being competent enough in Javascript and having some experience in Ruby and Python. For my education, I've written a function that parses a roman numeral ...
5
votes
2answers
88 views

Convert Exponential (e-Notation) Numbers to Decimals

I have the following short function code that converts Exponential (e-Notation) Numbers to Decimals, allowing the output of large number of decimal places. I needed to cover all the e-notation ...
5
votes
1answer
206 views

Converting a hexadecimal string to a binary string using Rust pattern matching lookup

I am getting started in Rust, and as a part of my first exercise, I decided to write a small program that converts a hexadecimal string to a binary string using a pattern matched lookup. I would ...
5
votes
1answer
113 views

Convert numbers from base X to base Y

I recently wrote a piece of code to convert between two bases of X, (Where 26 > X > 0). I was mighty proud that I did this. And then I started wondering, am I using modern coding conventions/practices?...
5
votes
1answer
57 views

“Bigint” decimal to two's complement binary list of bytes in Python

I'm toying with the idea of writing a "bigint" library in 6502 assembler that would handle variable-length integers up to 255 bytes long. Since this would be unit tested using pytest, and to help wrap ...
5
votes
1answer
1k views

Base conversion: decode and encode base to integer

I encountered this question as I am preparing for my code interview. I was implementing a base function that can decode and encode any bases from base 2 to base 36. I think my ...
4
votes
4answers
1k views

Roman numerals to Arabic

I've been learning to code for quite some time and my impression from the programming book I have is: "Keep it as simple as possible, but no simpler." I had an assignment to write a program that ...
4
votes
2answers
14k views

Hexadecimal number to decimal conversion

I am a semi-beginner in C++ and I have a project in C++ to convert a hexadecimal integer into decimal equivalent, but I extended it and now this program can also convert a fractional part. Logic I ...
4
votes
2answers
267 views

Converting hex to integer

What's the fastest way of doing this? ...
4
votes
2answers
103 views

Program to convert number from any base to decimal

I have made a script to convert number from any base to decimal. I am trying to optimize the code because I think it is bloated and can be improved but if I change anything it affects error handling ...
4
votes
2answers
365 views

Converting an integer to Greek and Roman numerals

Yesterday I posted a question about converting an integer to it's Roman Numeral equivalent. Apparently you guys liked it and gave me some good advice, so I decided to take all your advice, and go a ...
4
votes
1answer
286 views

Converting long values in Java to unsigned strings

This one is a research attempt to find out how to convert long values as unsigned long integers to Strings. It is much slower ...
4
votes
1answer
799 views

Python binary calculator

My task was to build a calculator in Python supporting binary addition etc. To begin I define a couple of custom exceptions : ...
4
votes
1answer
175 views

Convert boolean list to list of base10 integers

Context: I'm coding up a simple genetic optimization algorithm from first principles, and have decided to use boolean/binary strings as genes so that I can flip bits on or off as a form of mutation. ...
4
votes
2answers
9k views

JavaScript function to convert decimal number to binary

I was recently asked this in an interview for a front-end position and I came up with something like the code below, which seems to work but is clunky. (...
4
votes
1answer
7k views

All-in-one number base converter

I coded this program as a challenge for /r/dailyprogrammer. Basically this program can convert any number from any base to another base including negative bases as long as the input is coherent. Did I ...
4
votes
3answers
105 views

Function to represent an integer in a base

This function represents an integral type and represents it in a base. ...
4
votes
2answers
60 views

Base object to convert positive numbers into other bases (2 <= base <= 35) in Python

I'm fairly new to Python (this is the first thing I've done that really takes advantage of classes). This works and I'm happy with it; just looking for general advice. Especially nice would be input ...
4
votes
2answers
3k views

Excel-like column numbering

I have a working code (below) to convert a number to Excel-like (A...Z AA...AZ BA...BZ ...ZA-ZZ) column codes (headers). For ...
4
votes
1answer
952 views

Program to convert binary to hex

I wrote this program to convert binary to hex, it ignores other characters between the binary digits. I would like to receive any recommendations on how to improve it. ...
4
votes
1answer
451 views

Converting a binary string to hexadecimal using Rust

Once again, I am reinventing the wheel here to understand the fundamentals of rust. In a previous question I requested feedback on my function that performed a hexadecimal to binary conversion. In ...
4
votes
1answer
2k views

Decimal to Binary in Rust

As a beginner in Rust i am trying to practice Rust with some little programs so here is my implementation of Decimal to Binary. ...