Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Anyone fancy a challenge  (Read 2151 times)

0 Members and 1 Guest are viewing this topic.

reddevilggg

    Topic Starter


    Expert

    Thanked: 69
  • Experience: Beginner
  • OS: Windows 7
Anyone fancy a challenge
« on: February 03, 2011, 03:39:00 PM »
Wonder if anyone could clear something up for me.
I'm going through a tutorial sheet from University but it has no answers to check against.
One of the questions is 'Convert the following decimal into Little Endian single precision floating point format'

The decimal is -0.000123

The answer i get is

B9 00 F9 80

Thing is, i downloaded a calculator that claims to do Big and Little Endian, so i can check my answers

http://www.wfwsoftware.com/hexit.html

But this calc gives a different answer - B9 00 F9 90 - one digit difference
I checked my answers three times and i still get the same outcome, if the calculator is right then i cant see where i've gone wrong.
Can any one confirm my answer.
Thanks
11 cheers for binary !

BC_Programmer


    Mastermind
  • Typing is no substitute for thinking.
  • Thanked: 1140
    • Yes
    • Yes
    • BC-Programming.com
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Windows 11
Re: Anyone fancy a challenge
« Reply #1 on: February 03, 2011, 04:08:24 PM »
I get:

90 F9 00 B9.

the second answer you got from the calc was in Big-endian format; your's, well, I don't know.

Mine uses IEEE 32-bit floating point.

http://en.wikipedia.org/wiki/Single_precision



I was trying to dereference Null Pointers before it was cool.

reddevilggg

    Topic Starter


    Expert

    Thanked: 69
  • Experience: Beginner
  • OS: Windows 7
Re: Anyone fancy a challenge
« Reply #2 on: February 03, 2011, 04:33:33 PM »
Yeah, thats right, you got to reverse it for Little Endian.

This is what i've been taught, I have to work it out by hand for forthcoming tests. No calculators allowed.

I got 1 for the sign (obviously, because of the negative value)

0.00000000000010000000111110011000 is 0.000123 in binary

then to 1.0000000111110011000 x 2^-13

remove the first 1 and decimal point and 'pad out' to 23 bit by adding 0's the the end

So 00000001111100110000000

then -13 - -127 = -13+127 = 127-13 = 114 

So, 144= 01110010 for the exponent

bring it all together

Sign 1  exponent 01110010 and mantissa 00000001111100110000000

which is 10111001000000001111100110000000

split into groups of 4 to convert to hex

1011 / 1001 / 0000 / 0000 / 1111 / 1001 / 1000 / 0000

Which makes B 9 0 0 F 9 8 0

Then group and reverse 80 F9 00 B9

Can you see anywhere that i've gone wrong, cuz i still cant see it.
Oh yeah, thanks for the reply.
11 cheers for binary !

reddevilggg

    Topic Starter


    Expert

    Thanked: 69
  • Experience: Beginner
  • OS: Windows 7
Re: Anyone fancy a challenge
« Reply #3 on: February 03, 2011, 04:46:31 PM »

I think ive sussed it

0.000123 is 0.00000000000010000000111110011001

and not 0.00000000000010000000111110011000

Thats the difference, that last digit will turn the 8 to a 9

11 cheers for binary !

reddevilggg

    Topic Starter


    Expert

    Thanked: 69
  • Experience: Beginner
  • OS: Windows 7
Re: Anyone fancy a challenge
« Reply #4 on: February 04, 2011, 12:08:51 AM »

It amazes me that i was attempting to work this out for hours, then 15 mins after my second post and i spot the mistake. Strange how these thing happen!  :)
11 cheers for binary !

Quantos



    Guru
  • Veni, Vidi, Vici
  • Thanked: 170
    • Yes
    • Yes
  • Computer: Specs
  • Experience: Guru
  • OS: Linux variant
Re: Anyone fancy a challenge
« Reply #5 on: February 04, 2011, 04:53:14 PM »
It amazes me that i was attempting to work this out for hours, then 15 mins after my second post and i spot the mistake. Strange how these thing happen!  :)
It happens, at least you got it sorted out.
Evil is an exact science.