All Questions
Tagged with number-systems reinventing-the-wheel
18 questions
4
votes
0
answers
929
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, ...
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 ...
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.
...
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 ...
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 ...
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, (...
5
votes
2
answers
258
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:
...
0
votes
1
answer
561
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 ...
8
votes
3
answers
8k
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:
...
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 ...
3
votes
1
answer
683
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.
...
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 ...
0
votes
1
answer
1k
views
Binary to decimal converter in JavaScript
This exercise with a test suite is from here. I did not intend to use ES6 features, it's plain old JavaScript. That's why I seek advice more on the good practices, performance side, than modern syntax....
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.
...
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 ...
3
votes
1
answer
448
views
itoa with "method of complements" for negative numbers in ANSI C
I have enhanced my itoa implementation, taking the advise from my previous simple itoa implementation in addition to handling multiple radixes and negative numbers other then just base 10. Looking for ...
4
votes
2
answers
10k
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. (...