converting binary to hex
Moderator: MaxCoderz Staff
-
- Calc Wizard
- Posts: 680
- Joined: Wed 22 Dec, 2004 5:37 am
- Location: West Palm Beach,FL
- Contact:
converting binary to hex
Is there an efficient way to do this? Right now im just converting the binary to base 10 and from there converting it to hex. It takes too much time.
-
- Sir Posts-A-Lot
- Posts: 250
- Joined: Mon 31 Jan, 2005 4:37 pm
- Location: Somewhere over the rainbow
- Contact:
you could make a program to do it for you?
Reginald Tucker (Gimpynerd) www.gimpynerd.com
Amateur Programmer / Game Designer
Want to learn Z80 assembly? E-mail me at gimpynerd@gmail.com to set up a time for lessons!
Amateur Programmer / Game Designer
Want to learn Z80 assembly? E-mail me at gimpynerd@gmail.com to set up a time for lessons!
-
- Sir Posts-A-Lot
- Posts: 250
- Joined: Mon 31 Jan, 2005 4:37 pm
- Location: Somewhere over the rainbow
- Contact:
or...do this:
add 80 for the 7th bit, 40, for the 6th. 20 for the 5th, 10 for the fourth, 08 for the 3rd, 04 for the 2nd, 02 for the 1st, 01 for the 0th...
0th? idk man just go with the flow...hope that helps...
add 80 for the 7th bit, 40, for the 6th. 20 for the 5th, 10 for the fourth, 08 for the 3rd, 04 for the 2nd, 02 for the 1st, 01 for the 0th...
0th? idk man just go with the flow...hope that helps...
Reginald Tucker (Gimpynerd) www.gimpynerd.com
Amateur Programmer / Game Designer
Want to learn Z80 assembly? E-mail me at gimpynerd@gmail.com to set up a time for lessons!
Amateur Programmer / Game Designer
Want to learn Z80 assembly? E-mail me at gimpynerd@gmail.com to set up a time for lessons!
- Jim e
- Calc King
- Posts: 2457
- Joined: Sun 26 Dec, 2004 5:27 am
- Location: SXIOPO = Infinite lives for both players
- Contact:
Binrary to hex is simple in your head. It easier than to decimal.
You really only have to convert 0-15 nothing else
It's not hard really.
0000b = 00h
0001b = 01h
0010b = 02h
0011b = 03h
0100b = 04h
0101b = 05h
0110b = 06h
0111b = 07h
1000b = 08h
1001b = 09h
1010b = 0Ah
1011b = 0Bh
1100b = 0Ch
1101b = 0Dh
1110b = 0Eh
1111b = 0Fh
You really only have to convert 0-15 nothing else
It's not hard really.
0000b = 00h
0001b = 01h
0010b = 02h
0011b = 03h
0100b = 04h
0101b = 05h
0110b = 06h
0111b = 07h
1000b = 08h
1001b = 09h
1010b = 0Ah
1011b = 0Bh
1100b = 0Ch
1101b = 0Dh
1110b = 0Eh
1111b = 0Fh
-
- Calc Wizard
- Posts: 526
- Joined: Tue 08 Mar, 2005 1:37 am
- Location: who wants to know?
- Contact:
In Basic, I find it easier to go from one to the other via decimal.
Code: Select all
{1,0,1,0,1,0,0,1->L1
sum(L1seq(2^I,I,dim(L1),1,-1
int(16fPart(Ansseq(16^I,I,int(-dim(L1)/4),-1
Last edited by DarkerLine on Sat 21 May, 2005 11:32 pm, edited 1 time in total.
So, let's say you want to convert this 32-bit #:Jim e wrote:0000b = 00h
0001b = 01h
0010b = 02h
0011b = 03h
0100b = 04h
0101b = 05h
0110b = 06h
0111b = 07h
1000b = 08h
1001b = 09h
1010b = 0Ah
1011b = 0Bh
1100b = 0Ch
1101b = 0Dh
1110b = 0Eh
1111b = 0Fh
Code: Select all
01101010100101011101111101010101
Code: Select all
0110 1010 1001 0101 1101 1111 0101 0101
Code: Select all
6 A 9 5 D F 5 5
And this is one reason why hexadecimal is the preferred base-of-choice when it comes to machine code! (excluding those hard-core binary-ists )
"If SOURCE is outlawed, only outlaws will have SOURCE."
- kv83
- Maxcoderz Staff
- Posts: 2735
- Joined: Wed 15 Dec, 2004 7:26 pm
- Location: The Hague, Netherlands
- Contact:
I know. I am cleaning up the programming help section, which should be modded strictly... I was just a little slobby in the last time, so things got out of hand.lecks wrote:-OFF TOPIC- ur doing alot of moving around today. i keep seeing stuff with like 100 posts that ive never seen before, then i click on them and i c u saying u moved it.