Skip to main content

All Questions

Filter by
Sorted by
Tagged with
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, ...
Nate Eldredge's user avatar
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 ...
nexus_2006's user avatar
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. ...
S0AndS0's user avatar
  • 968
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 ...
Harvey's user avatar
  • 75
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 ...
sc_ray's user avatar
  • 1,213
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 ...
sc_ray's user avatar
  • 1,213
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, (...
ken's user avatar
  • 97
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: ...
Mr Pro Pop's user avatar
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 ...
Hum4n01d's user avatar
  • 111
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: ...
user avatar
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 ...
NinjaG's user avatar
  • 2,489
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. ...
user avatar
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 ...
saluyotamazing's user avatar
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....
Antonin Cezard's user avatar
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. ...
Confettimaker's user avatar
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 ...
Confettimaker's user avatar
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 ...
Matthew Hoggan's user avatar
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. (...
WinchenzoMagnifico's user avatar