[C] Question about converting IEEE-754 via /r/learnprogramming


[C] Question about converting IEEE-754

My assignment is to take a bit sequence (32 bits) in IEEE-754 representation like this:

00111010000111111111011000001000

And using C, convert it to scientific notation like this: 6.102030 * 10-4

 

When I look up how to do this on the internet, i'm seeing TONS of stuff on how to convert the bit sequence to the x * 2y format, like this:

signbit | exponent | mantissa

0 | 01110100 | 00111111111011000001000

And then plugging all of those values into the formula (-1)s × (1 + m) × 2e, where s = signbit, m = mantissa , e = exponent. If you don't know what I'm referring to here's a youtube video.

 

The problem is this gives me an answer in x * 2y format, but I need it in x * 10y (scientific notation). Is it valid for me to convert 2y to 10y, or am I going about this the wrong way? How would I go about getting this into scientific notation in C?

Submitted July 09, 2017 at 03:01PM by programmergirl28
via reddit http://ift.tt/2u7nISp

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s