Questions tagged [number-systems]

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

Filter by
Sorted by
Tagged with
3
votes
0answers
58 views

Early Stages of floating point class template in C++

I'm currently designing a class template to represent scientific notation or a floating-point number system. There are currently 4 distinct types: BIN, ...
3
votes
1answer
75 views

Indian Numbering System - converting into the Official and Common-Use Numbering Systems Words/Strings

I have developed the following short JavaScript function to convert numbers to the Indian Numbering System formats; both the Official Numbering System and the Common-Use System (i.e. using the Lakh-...
4
votes
0answers
35 views

Simple Pretty-Bytes Size (SI System)

This is a simple and short "Pretty Bytes" javascript function using the SI Decimal System for quantifying bytes. The code does not use complex maths such as ...
2
votes
1answer
75 views

JavaScript — Convert decimal to another base

The Source code is maintained on GitHub and may be cloned via the following commands. A Live demo is hosted online, thanks to GitHub Pages. ...
3
votes
0answers
74 views

Large Number Scales Names Generator

This JavaScript code generates the full name of the numeral scales for large numbers under the "Short Scale Numeral System" using the Conway-Guy system for forming number prefixes. Some very ...
4
votes
2answers
104 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 ...
5
votes
2answers
103 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
62 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 ...
4
votes
1answer
541 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 ...
10
votes
3answers
975 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)...
5
votes
1answer
238 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 ...
1
vote
1answer
250 views

Hex string to Base64 in Haskell

This is my take on the first challenge on the cryptopals crypto challenges list. I think that i made it quite simple but i feel like it is possible to optimize it further. Any suggestion? The code: ...
5
votes
4answers
126 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 ...
9
votes
4answers
403 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/...
3
votes
1answer
64 views

Interactive command-line binary to decimal converter

Is this the most efficient way to write this piece of code? Is there a better way of handling errors inside of a while/for loop, instead of calling back to the original function? I have tried using <...
4
votes
1answer
289 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 ...
3
votes
1answer
120 views

Convert characters to octal, binary, and integer

I have implemented a sample program that converts vector of characters to its integer representation depending on the bit size specified. I was hoping to get some input on how to simplify the sequence....
2
votes
1answer
95 views

256-bit ASCII Color Encoded Hex Dump in C

I made this hex dump after being dissatisfied with the free hexdumps out there. The biggest dissatisfaction is that the encodings for the char bytes were not color encoded, just like the hexyl hexdump ...
1
vote
2answers
91 views

Convert a number from one base to another

I wrote a function to convert an unsigned integer number given by a string from one base to another. Can you please give me any tips to improve it? ...
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 ...
4
votes
1answer
910 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 : ...
0
votes
2answers
79 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
49 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
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. ...
8
votes
5answers
405 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
783 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
272 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: ...
0
votes
1answer
28 views

Given an integer, return its binary representation. You cannot use any Integer.toXXXString methods

Here is my code: ...
1
vote
1answer
304 views

Converting decimal to octal

This is a simple program converting user input decimal numbers into octal ones. ...
4
votes
1answer
178 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
208 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
208 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
307 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
114 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?...
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: ...
1
vote
2answers
304 views

Decimal to binary and binary to decimal convertor

Please review this code. How can I optimise this code? ...
5
votes
1answer
353 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
774 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
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 ...
6
votes
4answers
385 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? ...
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 ...
2
votes
1answer
2k 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
230 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
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 ...
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
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 ...
3
votes
2answers
518 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
879 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
102 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
2k 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 ...