Questions tagged [base-conversion]

Base conversion is the process of changing the base of the textual representation of a number to another base. For example, "1010" in binary to "10" in decimal is a base conversion.

Base conversion is the process of changing the base of the textual representation of a number to another base. For example, 1010 in binary to 10 in decimal is a base conversion.

198 questions
0
votes
1 answer

Generate unique string using a string as a 'key' in PHP

I need to generate a unique string in PHP. Currently I'm using a technique like this $clipId = base_convert(microtime(), 8, 36); However, as this is based on time, the ID changes when the page is re-rendered, and I need to to always remain the…
Jack Wild
  • 2,072
  • 6
  • 27
  • 39
0
votes
2 answers

Exotic base conversion without an intermediate value?

I was just implementing an arbitrary base converter, and I had a moment of curiosity: is there a generalizable base conversion approach that works with any possible range of base inputs (excluding base 0), AND does not use an intermediate value in a…
hwbehrens
  • 25
  • 5
0
votes
1 answer

Overwrite a string in C

I'm trying to create a code that converts a decimal into any base between 2 and 16. But I don't know how to write a new value in my string. void base_conversion(char s[], int x, int b) { int j, y; j = 0; // your code here while(b > 1 && b < 17) { …
0
votes
2 answers

How do I convert a decimal to hexadecimal using Objective C?

I've been working on a calculator and I wanted to implement conversions from decimal to octal and from decimal to hexadecimal. I'm new to Xcode and Objective C, but I've managed to get a conversion from decimal to octal, it just doesn't seem to work…
user3062299
  • 55
  • 2
  • 5
  • 10
0
votes
3 answers

How can I convert my input String to an integer with a base conversion

I want my code whenever I input a base from 2-36 , It can output a number which is decimal. here is my code package code; public class solution{ public static int x2ten(String s, int base){ String[] bits = s.split(""); int…
users1141df
  • 19
  • 1
  • 6
0
votes
1 answer

Converting a number in any base to decimal in Java

I'm trying to use this method to convert a number in any base to decimal. public static int convertToDecimal(String str, int base){ int v = 0; int total = 0; int pow = 0; str = str.toUpperCase(); for(int i =…
user3283997
0
votes
0 answers

Why does this base conversion algorithm fail?

I'm trying to convert from some base (2-9) to base 10. The way this has to be done involves a lot of conversion between strings and integers because the function has to spit out a string, but it takes three arguments: the number to convert, the…
0
votes
1 answer

Converting a number in one base to another base using recursion

So im having trouble with creating a recursive function to convert a number from bases 2-10 to bases 2-16. I need it to return a string (obviously , due to the bases greater than 10). here is my function: main would call it like: answer =…
0
votes
0 answers

Base Conversion with a decimal point in C++

I am struggling to come up with an algorithm in C++ that converts a number with a decimal point from a base to any other base. I have successfully been able to write a function that converts numbers without decimal points to any desired base.…
0
votes
1 answer

What is the algorithm to convert a float of a base to the float of another base?

I would like to ask if someone of you knows how to achieve this: Let's say I have a float like 0.56 but with the base N and I want to convert it into a float with a base T, how can I achieve it? Is there a formula or something? For example, if I…
tonix
  • 6,671
  • 13
  • 75
  • 136
0
votes
5 answers

How to convert a decimal to binary using for loops?

/* This program converts decimal to binary */ import javax.swing.JOptionPane; public class BinaryLoop { public static void main(String []args) { String askForDecimal = JOptionPane.showInputDialog("Enter the decimal number you would like to…
TheJuggler
  • 78
  • 1
  • 1
  • 7
0
votes
0 answers

Base conversion of large integers using java

I have written the following code: public String alphabets = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ#$%"; public Integer findBase(String input) { int i = 0; Integer base = 0; Integer temp = 0; while (i !=…
0
votes
1 answer

Converting from decimal to non-decimal and printing(no strings, arrays and recursion)

Need help with a idea of how to convert a decimal number to non-decimal form(any, given by user input) and print it. The limitations are that arrays and strings are not allowed and while I wrote a recursive function for that, I am thinking of a…
Sunspawn
  • 817
  • 1
  • 12
  • 27
0
votes
0 answers

converting decimal to hex assembly

I'm trying to write a long program that converts a decimal input to a hexadecimal input and octal and so on. I pretty much did everything but I got a little bid stuck in the hexadecimal part. I know that I have to divide the number by 16 until the…
rullzing
  • 622
  • 2
  • 10
  • 22
0
votes
1 answer

Java base conversion program given value, its base, and new base

I am trying to figure out how to convert any value in a specific base to its corresponding representation in a different base. You are given a value, its base, and the base the value needs to be converted to in each line in a .dat file. Example of 3…
user2880377
  • 1
  • 1
  • 2