memorymap in visual studio

Hi

In visual studio, memoryMap shows values in 32 bit foat, unsigned int, int etc. However, if you convert from a 32 bit float to an int, how come the final value of the number looks so different?

How come 1.0863247e+009 float looks not 1 if i change the viewing format to int? I know the bits are stored differenty for float, ints - but is there a view for the memoryPane to display the numbers in a way that casting of one format to another works?
LuckyLucksAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sarabandeCommented:
How come 1.0863247e+009 float looks not 1 if i change the viewing format to int?
e+009 means *10^9. so the integer result is 10863247 and not 1.

a float is 32 bit and has 3 components: sign, exponent, mantissa . a very good explanation of the IEEE format is at http://steve.hollasch.net/cgindex/coding/ieeefloat.html

since sign is 1 bit, exponent is 8 bit and mantissa is 23 bit we may have odd numbers when looking at them as bytes (8-bit) or integer (8, 16 or 32 bit). because of that 'casting' a float to an int actually is not to look differently to bit sequences but is a conversion and can't be done easily in a hex viewer.

Sara
0
LuckyLucksAuthor Commented:
is there a way to interpret the integer being displayed in the memory pane's hex viewer?  I can read off the integer and use a third party tool to convert it ?
0
sarabandeCommented:
an integer normally is 32 bit. so it is a sequence of 4 (hex) bytes with "highest" byte to the right. you can calculate the integer by

(b1 * 0x1) + (b2 * 0x100) + (b3 * 0x10000) + (b4 * 0x1000000)

that sounds complex but actually the result simply can be computed by ordering the hex bytes into reverse order.

for example if you have sequence EE 01 2A 20 the result simply is 0x202A01EE what is 539623918 decimal.

so the only tool you need is the windows calculator with the programming view where you could switch from decimal to hex and reverse.

Sara
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual C++.NET

From novice to tech pro — start learning today.