Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [number-systems]

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

0
votes
2answers
65 views

Convert number to X base

As an educational exercise, I would like to make this code more efficient, with fewer lines, without using other standard functions. The goal here is to convert a number to X base and display it, (...
1
vote
1answer
43 views

Simple Binary to Decimal Converter

I just recently began going over number systems again, granted I didn't pay very much attention to it the first time for lack of understanding its importance (I've only been coding for a year and some ...
4
votes
1answer
58 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. ...
7
votes
5answers
296 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 ...
5
votes
3answers
118 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: ...
3
votes
3answers
250 views

Calculate with numbers from different number systems

This program calculates with numbers from different number systems and outputs the result in the desired number system. You call it like that: ...
1
vote
1answer
124 views

Converting decimal to octal

This is a simple program converting user input decimal numbers into octal ones. ...
4
votes
1answer
146 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. ...
5
votes
2answers
153 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: ...
6
votes
2answers
191 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 ...
0
votes
1answer
237 views

Binary to decimal in python

binaryToDecimal = lambda binary: sum([[int(2**index) for index in range(len(binary))][-index-1] for index, char in enumerate(binary) if int(char)]) I wrote a ...
5
votes
1answer
100 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?...
7
votes
3answers
2k 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: ...
1
vote
2answers
207 views

Decimal to binary and binary to decimal convertor

Please review this code. How can I optimise this code? ...
5
votes
1answer
203 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 ...
6
votes
1answer
295 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,...
4
votes
4answers
616 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 ...
6
votes
4answers
278 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? ...
8
votes
6answers
2k 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 ...
2
votes
1answer
628 views

Multiplying binary numbers digit by digit and carry method in Python

I have two numbers encoded in a reversed list of digits. First I made multiplication in "Peano" way: ...
4
votes
1answer
107 views

C++ with Qt - Conversion of angle in radians to DDD°MM′SS.FFF″ string

I had to write a function which takes an angle in radians and precision N as input and returns a string representation of its magnitude in the format DDD°MM′SS.FFF″ ...
5
votes
1answer
701 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 ...
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: ...
6
votes
3answers
100 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 ...
3
votes
2answers
356 views

Base Conversion in Node.js

I am doing a program for my APCS class in Node.js to practice node, but I am unsure if I did everything the best way possible. The assignment is to take the number and base as user input and then ...
6
votes
1answer
522 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 ...
3
votes
2answers
100 views

355 - The Bases Are Loaded (math numbers conversion)

Recently I found this task, which is to convert numbers between arbitrary bases. My code is working fine, but time limit exceeded. ...
1
vote
1answer
1k views

Binary calculator

I made a Binary Calculator that gives the user's the decimal value of their input. I tried to make my code as small as possible but I feel like there's still too much lines of code for such a simple ...
4
votes
3answers
98 views

Function to represent an integer in a base

This function represents an integral type and represents it in a base. ...
2
votes
1answer
920 views

Convert number from one radix to another

I am relatively new to coding and could use some help figuring out how I could improve my coding technique and habits. Here's an example of a working Java program I wrote that converts a number of ...
6
votes
2answers
796 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
5k views

Convert Persian and Arabic digits to English

I use the following utility method to convert Persian and Arabic digits to English using regex: ...
3
votes
1answer
66 views

Is this an efficient implementation of the Roman Numeral Converter?

Is this an efficient way to implement the Roman Numeral Converter ? So first, I put all the digits of the parameter number into an array. Then I loop through this array, and multiply a 10 power ...
1
vote
2answers
107 views

Generic numerical systems conversion

This program is a start point to a more comprehensive program that deals with different numerical systems from binary until 35 base. That includes the traditional decimal, octal and hex. It is until ...
3
votes
1answer
2k views

Implementing Addition, subtraction, multiplication, division of numbers of different base and give result in desired base:

Implement addition, subtraction, division and multiplication of given numbers of different base and provide result in desired base: Example: n1,b1 = 1010, 2 n2,b2 = 100, 10 ...
4
votes
2answers
54 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 ...
7
votes
1answer
5k 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 ...
3
votes
1answer
475 views

Convert number from base-10 number system to any number system

I wrote a small method for convert number from base-10 number system to any number system (code is not perfect but that is not the point). My question is if I get right single responsibility principle....
3
votes
1answer
629 views

Integer to binary using an old-school way

I know I could achieve this using System.out.println(Integer.toBinaryString(num)); in Java. However, I wanted to do it this way. ...
1
vote
2answers
94 views

Generate new latitude and longitude in decimal

I have created simple algorithm to generate the new Location from given latitude and longitude. ...
4
votes
1answer
441 views

Binary to decimal conversion and vice-versa

I need to write a code for conversion between the decimal numbers and binary numbers. I have tried the problem and what I have is 3 classes and 1 enum type ...
3
votes
1answer
67 views

Bruteforcing PCP's in Python

I am trying to Bruteforce a PCP that is supposed to be up to the length 300. I wrote a little Python program that is doing just that but it could take forever until my program finds the right PCP. <...
1
vote
1answer
110 views

Base conversion [closed]

I wrote a base conversion program. This base conversion should also work with base 1 (unary) where 000 is 3 and 0000000 is 7 and so on. It is only for non-negative numbers. ...
4
votes
1answer
1k views

Decimal to Binary Conversion and vice-versa in Python

Given a decimal number I need to convert it into binary Given a binary number I need to convert it into decimal After the conversion I need to perform some operation on it (for example, addition). I ...
1
vote
1answer
73 views

Android UI for converting numbers from base system x to base system y

As a complete beginner, I didn't care about how the code looked as long as it works. However, now I am starting to think about how to make code be more maintainable and easier to read. I feel I have ...
4
votes
2answers
244 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 ...
3
votes
1answer
1k views

Implementing my own Integer.toBinaryString(int n) method

Our senior developer gave us (trainees/jr. developers) a small exercise and that is to make our own Integer.toBinaryString(int n) implementation. This is the answer ...
2
votes
3answers
37 views

Filtering out neighboring ascending digits in quaternary numeral system

Take in a natural number n ∈ N, then process and output a(n), with a(n) being the number of quaternary strings (with 0, 1, 2, 3) of length n, where (from left to right) there never follows a character ...
3
votes
2answers
234 views

Converting bits to decimal (integer) string is so slow

I am implementing myself a BigInteger class. It can natively handle very very big digits in very short time. ...