G oog le BadWeB | Login/out | Topics | Search | Custodians | Register | Edit Profile


Buell Forum » Quick Board » Archives » Archive through September 05, 2012 » Anyone converted decimal to hex? » Archive through August 23, 2012 « Previous Next »

Author Message
Top of pagePrevious messageNext messageBottom of page Link to this message

Cataract2
Posted on Thursday, August 23, 2012 - 10:35 am:   Edit Post Delete Post View Post/Check IP Print Post    Move Post (Custodian/Admin Only) Ban Poster IP (Custodian/Admin only)

I'm working out a problem and can not figure out how to do this. I know it's simple, but I need help. I'm trying to convert decimal to hexadecimal by hand. 1063.5 Anyone able to explain how to go about this?
Top of pagePrevious messageNext messageBottom of page Link to this message

Jaimec
Posted on Thursday, August 23, 2012 - 10:41 am:   Edit Post Delete Post View Post/Check IP Print Post    Move Post (Custodian/Admin Only) Ban Poster IP (Custodian/Admin only)

By hand? No, I'm afraid I've gotten far to used to doing it with a calculator (and the "Convert" built-in function).

It would be a series of "Divide by 16s" though.
Top of pagePrevious messageNext messageBottom of page Link to this message

Reindog
Posted on Thursday, August 23, 2012 - 11:18 am:   Edit Post Delete Post View Post/Check IP Print Post    Move Post (Custodian/Admin Only) Ban Poster IP (Custodian/Admin only)

Convert the integer and remainder parts separately.

1063 (base 10) = 427 (base 16)

0.5 = 5/10 = 8/16 so the converted value is

427.8 hex. Notice that the digit immediately to the right of the decimal is the 1/16th place.
Top of pagePrevious messageNext messageBottom of page Link to this message

Argentcorvid
Posted on Thursday, August 23, 2012 - 11:21 am:   Edit Post Delete Post View Post/Check IP Print Post    Move Post (Custodian/Admin Only) Ban Poster IP (Custodian/Admin only)

it depends on how it's encoded which will depend on the device you're putting the number into. general-purpose computers mostly use IEEE double-precision Floating point. If you're putting the number into an embedded device (like say the ECM), there might not be space for that, and they might use fixed point numbers, or in some cases only support integers.
Top of pagePrevious messageNext messageBottom of page Link to this message

Cataract2
Posted on Thursday, August 23, 2012 - 11:38 am:   Edit Post Delete Post View Post/Check IP Print Post    Move Post (Custodian/Admin Only) Ban Poster IP (Custodian/Admin only)

Rein, I understand the base 16. I just don't know how you got the 427. I figured out how to work the .5 part to get 8 through dividing 1063.5/16 which for my 66.46875. Then I multiplied 46875 by 16 which for me 7.5. rounding up for my the 8.

I just can't figure out how to get the 427.
Top of pagePrevious messageNext messageBottom of page Link to this message

Sifo
Posted on Thursday, August 23, 2012 - 11:39 am:   Edit Post Delete Post View Post/Check IP Print Post    Move Post (Custodian/Admin Only) Ban Poster IP (Custodian/Admin only)

Anyone else ever learn to do that with the tables on an IBM yellow card? Anyone else ever hear of an IBM yellow card?

427 is the correct answer BTW.
Top of pagePrevious messageNext messageBottom of page Link to this message

Sifo
Posted on Thursday, August 23, 2012 - 11:42 am:   Edit Post Delete Post View Post/Check IP Print Post    Move Post (Custodian/Admin Only) Ban Poster IP (Custodian/Admin only)

If you need the exact answer, it's 427.8

I'm far too lazy to work it our manually these days when computers can do it for you in a fraction of a second...
http://www.mathsisfun.com/binary-decimal-hexadecim al-converter.html
Top of pagePrevious messageNext messageBottom of page Link to this message

Danger_dave
Posted on Thursday, August 23, 2012 - 11:52 am:   Edit Post Delete Post View Post/Check IP Print Post    Move Post (Custodian/Admin Only) Ban Poster IP (Custodian/Admin only)

Hexadecimal is not as simple as #000 and #FFF. Sometimes there are shades of #333.
Enough to make you see #F00 sometimes.
Top of pagePrevious messageNext messageBottom of page Link to this message

Reindog
Posted on Thursday, August 23, 2012 - 11:53 am:   Edit Post Delete Post View Post/Check IP Print Post    Move Post (Custodian/Admin Only) Ban Poster IP (Custodian/Admin only)

Use the hex conversion button on your calculator. ; )

The easiest way is to convert an integer, N, into binary is successive divisions by 2 and retaining the remainder (0 or 1). This will yield the base 2 equivalent. For example, 1063 -> 10000100111. Conversion to hex from binary is trivial. Group each four-bits into hex. (0001->1,...,1001->9,...,1010->A, etc).

10000100111 -> 427 hex.
Top of pagePrevious messageNext messageBottom of page Link to this message

Natexlh1000
Posted on Thursday, August 23, 2012 - 12:00 pm:   Edit Post Delete Post View Post/Check IP Print Post    Move Post (Custodian/Admin Only) Ban Poster IP (Custodian/Admin only)

He's obviously doing this for school. Otherwise, there wouldn't be a fraction in there!

So that's why he can't just type in CALC.EXE and set "view" to scientific and then covert it the cheaty-way.

Calc.exe doesn't allow for hex fractions so that's probably a "gotcha" to see who is cheating.
Top of pagePrevious messageNext messageBottom of page Link to this message

Court
Posted on Thursday, August 23, 2012 - 12:05 pm:   Edit Post Delete Post View Post/Check IP Print Post    Move Post (Custodian/Admin Only) Ban Poster IP (Custodian/Admin only)

>>>0.5 = 5/10 = 8/16 so the converted value is

That's pretty slick . .. can you convert me?
Top of pagePrevious messageNext messageBottom of page Link to this message

Mr_grumpy
Posted on Thursday, August 23, 2012 - 12:10 pm:   Edit Post Delete Post View Post/Check IP Print Post    Move Post (Custodian/Admin Only) Ban Poster IP (Custodian/Admin only)

What would you like to be converted to Court?

Natural gas?
Buddhism?
Diesel?
or 12 year old single malt.
Top of pagePrevious messageNext messageBottom of page Link to this message

Jaimec
Posted on Thursday, August 23, 2012 - 12:33 pm:   Edit Post Delete Post View Post/Check IP Print Post    Move Post (Custodian/Admin Only) Ban Poster IP (Custodian/Admin only)

In my field, it's not 427, it's 0427 (two bytes)

Just sayin'
Top of pagePrevious messageNext messageBottom of page Link to this message

Court
Posted on Thursday, August 23, 2012 - 12:38 pm:   Edit Post Delete Post View Post/Check IP Print Post    Move Post (Custodian/Admin Only) Ban Poster IP (Custodian/Admin only)


quote:

Natural gas?
Buddhism?
Diesel?
or 12 year old single malt.





I can narrow it to two . . . and suspect, given my prior experience with Rein, I'm left with only the 12 Year Old Single Malt. Besides . . . as much as I'd like to be converted to a Buddhist . . . I'm not sure I'd be able to find my way ohm.

Beam me up . . . .
Top of pagePrevious messageNext messageBottom of page Link to this message

Brijasher
Posted on Thursday, August 23, 2012 - 12:39 pm:   Edit Post Delete Post View Post/Check IP Print Post    Move Post (Custodian/Admin Only) Ban Poster IP (Custodian/Admin only)

16^3 = 4096
16^2 = 0256
16^1 = 0016
16^0 = 0001

1063/(16^2) = 4 remainder 39
39/(16^1) = 2 remainder 7
7/(16^0) = 7

= 427
Top of pagePrevious messageNext messageBottom of page Link to this message

Kyrocket
Posted on Thursday, August 23, 2012 - 12:41 pm:   Edit Post Delete Post View Post/Check IP Print Post    Move Post (Custodian/Admin Only) Ban Poster IP (Custodian/Admin only)

That's baaaad
Top of pagePrevious messageNext messageBottom of page Link to this message

Brijasher
Posted on Thursday, August 23, 2012 - 12:46 pm:   Edit Post Delete Post View Post/Check IP Print Post    Move Post (Custodian/Admin Only) Ban Poster IP (Custodian/Admin only)

And for completeness:

16^3 = 4096
16^2 = 0256
16^1 = 0016
16^0 = 0001
16^-1= 0.625

1063.5/(16^2) = 4 remainder 39.5
39.5/(16^1) = 2 remainder 7.5
7/(16^0) = 7 remainder 0.5

0.5 < (16^-1) so stop dividing here and convert the digits

4 => 4
2 => 2
7 => 7
0.5 => 0.8

= 427.8
Top of pagePrevious messageNext messageBottom of page Link to this message

Reindog
Posted on Thursday, August 23, 2012 - 12:59 pm:   Edit Post Delete Post View Post/Check IP Print Post    Move Post (Custodian/Admin Only) Ban Poster IP (Custodian/Admin only)

In my field, 427 hex is 0x427 or 'h427, but I know you leading zero types. : )
Top of pagePrevious messageNext messageBottom of page Link to this message

Brijasher
Posted on Thursday, August 23, 2012 - 01:35 pm:   Edit Post Delete Post View Post/Check IP Print Post    Move Post (Custodian/Admin Only) Ban Poster IP (Custodian/Admin only)

You are absolutely correct, I missed the 6 steps required to properly add the leading '0x' =P

For my penance, you get to present the steps to convert to proper IEEE double precision floating point.
Top of pagePrevious messageNext messageBottom of page Link to this message

Cataract2
Posted on Thursday, August 23, 2012 - 01:44 pm:   Edit Post Delete Post View Post/Check IP Print Post    Move Post (Custodian/Admin Only) Ban Poster IP (Custodian/Admin only)

Brij, thanks for the explanation. Yes, I'm doing this for Digital Circuits. Starting my Electrical Engineering course. First day was yesterday and trying to get a jump. Frustrating myself instead. Brij, how did you get the remainder. When I run 1063.5/(16^2) through the calculator I get 4.154296875
Top of pagePrevious messageNext messageBottom of page Link to this message

Brijasher
Posted on Thursday, August 23, 2012 - 01:54 pm:   Edit Post Delete Post View Post/Check IP Print Post    Move Post (Custodian/Admin Only) Ban Poster IP (Custodian/Admin only)

Yup, go back to elementary school when you had to do long division by hand.

Take 4.15... and truncate it, then 1063.5 - (4 * 16^2) gives you 39.5
Top of pagePrevious messageNext messageBottom of page Link to this message

Reepicheep
Posted on Thursday, August 23, 2012 - 01:58 pm:   Edit Post Delete Post View Post/Check IP Print Post    Move Post (Custodian/Admin Only) Ban Poster IP (Custodian/Admin only)

Reindog beat me to it. 0427 is octal. : )

(You are flushing out all us embedded C programmers...)
Top of pagePrevious messageNext messageBottom of page Link to this message

Brijasher
Posted on Thursday, August 23, 2012 - 02:01 pm:   Edit Post Delete Post View Post/Check IP Print Post    Move Post (Custodian/Admin Only) Ban Poster IP (Custodian/Admin only)

Something that will speed this up is if you have a scientific calc that can give you the modulus.

I.e.
1039.5/256 = 4.15...
1039.5 mod 256 = 39.5
39.5/16 = 2.nnn
39.5 mod 16 = 7.5
Top of pagePrevious messageNext messageBottom of page Link to this message

Brijasher
Posted on Thursday, August 23, 2012 - 02:03 pm:   Edit Post Delete Post View Post/Check IP Print Post    Move Post (Custodian/Admin Only) Ban Poster IP (Custodian/Admin only)

Bah, I didn't say 0427 anywhere. Everyone's a critic. Yeesh.
Top of pagePrevious messageNext messageBottom of page Link to this message

Cataract2
Posted on Thursday, August 23, 2012 - 02:06 pm:   Edit Post Delete Post View Post/Check IP Print Post    Move Post (Custodian/Admin Only) Ban Poster IP (Custodian/Admin only)

Thanks Braij. Been a long time for me so I have some serious cobwebs to clear.
Top of pagePrevious messageNext messageBottom of page Link to this message

Argentcorvid
Posted on Thursday, August 23, 2012 - 02:06 pm:   Edit Post Delete Post View Post/Check IP Print Post    Move Post (Custodian/Admin Only) Ban Poster IP (Custodian/Admin only)


quote:

In my field, it's not 427, it's 0427 (two bytes)


and on intel machines it's stored 0x27 0x04.
Top of pagePrevious messageNext messageBottom of page Link to this message

Sifo
Posted on Thursday, August 23, 2012 - 02:08 pm:   Edit Post Delete Post View Post/Check IP Print Post    Move Post (Custodian/Admin Only) Ban Poster IP (Custodian/Admin only)

Can I hate the math and still like the mathematician?
Top of pagePrevious messageNext messageBottom of page Link to this message

Brijasher
Posted on Thursday, August 23, 2012 - 02:14 pm:   Edit Post Delete Post View Post/Check IP Print Post    Move Post (Custodian/Admin Only) Ban Poster IP (Custodian/Admin only)

Uh oh, here comes the big-endian, little-endian fight. Hmmm, which side do I want to make fun of more?
Top of pagePrevious messageNext messageBottom of page Link to this message

Brijasher
Posted on Thursday, August 23, 2012 - 02:18 pm:   Edit Post Delete Post View Post/Check IP Print Post    Move Post (Custodian/Admin Only) Ban Poster IP (Custodian/Admin only)

And for all you programmers, here is a little something for you to run at your nearest command line.
perl -e 'while 1{fork}'
Let me know how it works out for you. ; )
Top of pagePrevious messageNext messageBottom of page Link to this message

Cataract2
Posted on Thursday, August 23, 2012 - 02:27 pm:   Edit Post Delete Post View Post/Check IP Print Post    Move Post (Custodian/Admin Only) Ban Poster IP (Custodian/Admin only)

Hopefully I don't piss anyone off if I throw questions out from time to time regarding my classes. Sometimes a bigger pool helps with this stuff.
« Previous Next »

Topics | Last Day | Tree View | Search | User List | Help/Instructions | Rules | Program Credits Administration