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
1
vote
1 answer

Smallest positive number to trigger carry out

I'm following a course on Computer Architecture and I have the following exercise: What is the smallest positive decimal number that should be added to -20 so that a carry-out is triggered (in 2 complement's notation)? I solved this exercise, but…
user4424299
1
vote
3 answers

C# base converter

I stumbled on this method which should do a base convert from a 10 base to radix base, so for example if I pass 28, 16 it should return 1c which is the hexadecimal representation of the decimal 28 private static string convertTo(long value, int…
doc_id
  • 1,363
  • 13
  • 41
1
vote
3 answers

Division in base N

I was wondering if there was a specific algorithm for doing this in C. I came up with some approaches however. The problem: I have 2 numbers in base 7. The numbers are divisible, so my answer will always be an integer. I wish to calculate the…
someone1
  • 115
  • 1
  • 11
1
vote
1 answer

Why do these base converters give different answers?

I have written a python program to convert numbers from any positive integer base to another. print("Base Converter") from math import log print("This converter uses 0-9, followed by A-Z, followed by a-z, giving it individual characters from 0 -…
FaceySmile
  • 53
  • 9
1
vote
5 answers

PL/SQL base conversion without functions

Is there any way to convert decimal to binary, or binary to decimal, in Oracle 10g without having to first define a function? I have limited database access (SELECT only) and all the solutions for this I've found online seem to involve CREATE…
Sarah Vessels
  • 30,930
  • 33
  • 155
  • 222
1
vote
2 answers

How can I convert a number in a string to any base in assembly?

How can I convert a number contained in a string from any base to any other base? Bases can be anything i.e.: 2, 16, 10, 4, 8, 9. I'm expecting the user to enter the base number. The user will enter the output base (the base to be converted to). The…
Nick
  • 155
  • 1
  • 8
1
vote
3 answers

conversion from any base to base 10 c++

I found two ways of conversion from any base to base 10 . the first one is the normal one we do in colleges like 521(base-15) ---> (5*15^2)+(2*15^1)+(1*15^0)=1125+30+1 = 1156 (base-10) . my problem is that i applied both methods to a number…
Altaf Hussain
  • 25
  • 1
  • 1
  • 6
1
vote
4 answers

Recursive function to convert between number bases fails at certain numbers

I'm trying to a create an algorithm that can convert base 10 numbers into base n numbers, where n is at most 10. However, for some weird reason the following algorithm in C fails at certain critical points for each base. For example, for base 2 and…
user3059347
  • 529
  • 1
  • 9
  • 15
1
vote
3 answers

Reverse custom base encode in PHP

I have a program that encodes integers into random looking, unique, maxiumum 5 character strings using a custom base array. I'd like to decode that string back to an integer. Not sure how to accomplish that. Code: function intToAlphaBaseN($n,…
Ted Scheckler
  • 1,389
  • 4
  • 16
  • 34
1
vote
1 answer

Convert Binary to Decimal in MIPS, Assembly MARS

I am trying to convert binary to decimal in the MIPS language, using the MARS simulator. The program accepts a binary number, and then does the conversion, by multiplying (shift left by the number's place $t9). Another way of saying that is…
user2827214
  • 1,191
  • 1
  • 13
  • 32
1
vote
1 answer

Need help converting numbers with decimals to other bases C#

I need help with a program in C# that has to convert any number (whether integer or long decimal) to any base (within reason). The program has several text boxes (it's a win form) all starting blank. When the user adds numbers (possibly with a…
Masoniik
  • 13
  • 4
1
vote
1 answer

What's wrong with this Decimal to Binary converter (without iteration)

I'm trying to make a code for converting decimal into binary for n<16 without using iteration. but the output is always either 1000, 100, 10 or 1. what is wrong with the code? thank you very much #include int main(void){ int decimal, bin…
Imran Ariffin
  • 185
  • 1
  • 8
1
vote
1 answer

Hex Twos Complement Arithmetic

I'm trying to do the following problem: E8B2035D -FB60528D ---------- In which, the integers represented are hex representations of 32-bit two's compliment binary numbers. What is the best approach to solve this problem, and detect overflow?
user1527185
1
vote
2 answers

Calculating an integer from its Bytes gives oddly wrong results

I'm trying to read an integer from a data file which is stored raw in little endian format. Once I got the corresponding bytes I originally calculated the integer value by adding the numbers multiplied by their weight (aritmetic method below) but…
NeonMan
  • 623
  • 10
  • 24
1
vote
4 answers

Bigger input base for bc?

I'm searching for a calculator in base 31, i.e., I want both input and output to be in base 31. (I actually don't care much about the format of digits, only that it would be easy writable. So, for example `013456789ABCDEFGHIJKLMNOPQRSTU' would be…