Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 132,050 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,232 people online right now. Registration is fast and FREE... Join Now!




converting 32 bit integers

 
Reply to this topicStart new topic

converting 32 bit integers

tootypegs
post 27 Jan, 2008 - 10:55 AM
Post #1


D.I.C Head

**
Joined: 9 Oct, 2007
Posts: 177


My Contributions


Hi, i have the following hex string 'C4 48 FD FF'. When using a calulator to convert it i do not get the value im after. The number im after converting it to is '-177980'. I think this is in 32 bit interger format??? anyway im not sure i understand how that is possible but my hex editor gives me that value from that hex string in the 32 bit data interpretor. Can anyone explain to me how this is converted? And is this possible to do in c++?

This post has been edited by tootypegs: 27 Jan, 2008 - 11:39 AM
User is offlineProfile CardPM

Go to the top of the page

Martyr2
post 27 Jan, 2008 - 11:49 AM
Post #2


Programming Theoretician

Group Icon
Joined: 18 Apr, 2007
Posts: 5,012



Thanked 171 times

Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions


hehe... its backwards. If you calculate 5357268 to hex you get 00 51 BE D4. So either your hex converter is going backwards or some other conversion is running the wrong way for you. Check that out and let us know if you have found out what is going on.

smile.gif

User is offlineProfile CardPM

Go to the top of the page

tootypegs
post 27 Jan, 2008 - 12:51 PM
Post #3


D.I.C Head

**
Joined: 9 Oct, 2007
Posts: 177


My Contributions


QUOTE(Martyr2 @ 27 Jan, 2008 - 12:49 PM) *

hehe... its backwards. If you calculate 5357268 to hex you get 00 51 BE D4. So either your hex converter is going backwards or some other conversion is running the wrong way for you. Check that out and let us know if you have found out what is going on.

smile.gif



hey thank you, my fault tho i put the wrong example up for post. the example i should have included was 'C4 48 FD FF' to '-177980'.

i just can't understand how this can happen?
User is offlineProfile CardPM

Go to the top of the page

tootypegs
post 28 Jan, 2008 - 08:02 AM
Post #4


D.I.C Head

**
Joined: 9 Oct, 2007
Posts: 177


My Contributions


AH!! i think ive cracked it but im not too sure how to code it in c++. First i hav the hex string 'C4 48 FD FF'. I have to convert to little endien format 'FF FD 48 C8' and convert to decimal. Then convert the decimal to binary so i get
'11111111111111010100100011000100'. Then i need to reverse the bits so that '1's' become '0's' and '0's' become '1's'. Then i convert that back to decimal and add 1. Is there an easy way to do this to a number in c++?


thanks
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/21/08 06:28AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month