Questions tagged [number-systems]
Questions about representing numbers in alternative representations, such as hexadecimal or Mayan
123 questions
4
votes
4
answers
415
views
Convert the number formats (Decimal - Hexadecimal - Octal) to Decimal
Problem statement:
Write a program called multi_input.cpp that prompts the user to enter several integers in any combination of octal, decimal, or hexadecimal, ...
9
votes
1
answer
288
views
Convert integer to Roman numeral string
This is my 1st time developing PHP code and I am only 13 years old. I have experience in other programming languages like lua, python, and c++.
This is a simple Number to Roman Numeral code I made for ...
4
votes
2
answers
8k
views
Printing a number in binary in C
I wrote a short function whose purpose is simple: Print the binary representation of number to the console. I also aim to be as portable as possible, hence my use of ...
3
votes
2
answers
261
views
Time and space complexity of base conversion code
I have an algorithm that performs the base conversion. The input is a string and two ints b1 and b2. The string represents an ...
2
votes
1
answer
322
views
Increment a binary number represented as a string
I'm an amateur at assembly, but am trying to get better at it. For fun, I decided to write code that takes in a char array and increments the number represented in binary.
Here are a few input-output ...
8
votes
2
answers
2k
views
Encode and decode string as base-32 number
I wrote a program that can take any English text and transform it into an integer and vice versa.
My method
I use two dictionaries to map between letters and numbers. I chose base 32 because it is a ...
4
votes
1
answer
282
views
Decibinary for xth number (Python code)
I created the code for the problem description below. It works for \$N\le10^6\$ but after that it gives a time out error. What I don't understand is how to optimize the code using dynamic programming. ...
14
votes
1
answer
10k
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
...
2
votes
2
answers
435
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.
...
0
votes
3
answers
177
views
Convert from decimal to binary and octal
I wrote a program that implements an algorithm that converts from decimal to binary and octal
Please criticize my implementation. What else can I do to improve?
...
5
votes
1
answer
232
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 ...
3
votes
1
answer
238
views
Python 3 number convertor that converts floats between decimal and bases 2-36
This is a Python 3 script that converts any real number (ints and floats) from decimal notation to any positional number system ...
4
votes
4
answers
2k
views
Convert Integer to Binary String
This code takes a user input number which is a positive integer, and outputs a string representation of the number in binary. For example, input 2 outputs ...
1
vote
1
answer
649
views
Converting decimal to binary in Assembly
The longest example program in my PicoBlaze Simulator in JavaScript is this decimal-to-binary converter:
...
0
votes
3
answers
267
views
Fractional binary number to decimal number
Write and test your own double abc (char * b) function in the program, taking in the form of a string the fractional binary number of the form "1101.101" ...
0
votes
3
answers
876
views
5
votes
2
answers
4k
views
Represent integer as binary in C
To practice my C, I've written a small function in C to display an integer as an 8-bit binary number. Please let me know how to improve this function, and other C-style coding conventions. Thanks!
<...
5
votes
4
answers
3k
views
C++ basic bank money class
I am trying to create a basic money class that fits into a small console banking application I am making.
Money.h
...
0
votes
1
answer
71
views
2 ConvertToBase3 methods with great disparity of execution time
I have two methods to do the same thing: convert a number to ternary.
...
4
votes
1
answer
356
views
Number system converter GUI
This program converts from number system A to number system B as soon as you input something in it, as a rookie it took a lot of thinking to make it work a seamless and fool-proof way.
It converts ...
10
votes
3
answers
23k
views
Convert Persian and Arabic digits to English
I use the following utility method to convert Persian and Arabic digits to English using regex:
...
4
votes
0
answers
930
views
Binary to hex in ARM64 SIMD assembly
As an exercise in learning ARM64 assembly (aka AArch64), I wrote this function to convert 64-bit binary to hexadecimal with SIMD instructions. I'm most interested in feedback on the algorithm, ...
3
votes
0
answers
77
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, ...
4
votes
1
answer
2k
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-...
9
votes
4
answers
1k
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
0
answers
1k
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 ...
3
votes
1
answer
2k
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 ...
4
votes
2
answers
1k
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 ...
7
votes
2
answers
16k
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 ...
2
votes
1
answer
2k
views
Python binary to decimal converter (without using built-ins)
Any ideas how I could improve this? I already know that there is no checking for anything other than a 1, so you can enter a 2 ...
5
votes
1
answer
203
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
1
answer
2k
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 ...
7
votes
1
answer
4k
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 ...
10
votes
3
answers
1k
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)...
1
vote
1
answer
423
views
Python Decimal to Binary converter (without using bin() or output formatting)
There is no input validation for this, but that aside, I would appreciate it if anyone could help me improve the logic of this script.
...
1
vote
1
answer
872
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
4
answers
743
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 ...
3
votes
1
answer
108
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
1
answer
376
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
1
answer
510
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
1
answer
342
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
2
answers
365
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
3
answers
177
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
1
answer
5k
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
2
answers
121
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
1
answer
91
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 ...
5
votes
1
answer
13k
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
5
answers
2k
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
1
answer
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 ...
5
votes
3
answers
3k
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:
...