Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Help in Floating Point Representation

Status
Not open for further replies.

deepu_s_s

Full Member level 5
Joined
Mar 24, 2007
Messages
305
Helped
15
Reputation
30
Reaction score
5
Trophy points
1,298
Activity points
3,021
Hello Friends,

I wanted to represent 0.9808 in IEEE 754 format. Below i represented the number. Please check and correct the mistakes if any.

Single Precision floating point

0.9808 = 0.111110110

---> 0.111110110 = 1.11110110 * 2^-1

sign bit = 0
exponent = -1+127 = 126=01111110
significand = 11110110

IEEE 754 = 0 01111110 11110110_00000000_0000000

is this the correct representation of that number ?

Please answer me as soon as possible


Thanks and Regards
Deepak
 

You are close, but not quite correct. Try these on-line calculators:
**broken link removed**
**broken link removed**

They give this result:
00111111 01111011 00010101 10110101

GCC gives the same result (in hex) using this C code in Windows:
Code:
#include <stdio.h>
int main(void)
{
  union
  {
    float x;
    int i;
  } u = {0.9808};
  printf("%08X\n", u.i);
  return 0;
}
Output: 3F7B15B5

Remember that's not an exact representation of 0.9808. It has been rounded off to about 23 bits.
 

    deepu_s_s

    Points: 2
    Helpful Answer Positive Rating
HI Echo,

I think i did calculation for up to 9 decimal places. and i filled remaining bits with 0's . so does my representation is wrong?

Added after 2 minutes:

is it mandatory that we should calculate the value for all 23 bits in the significand
 

By zeroing the lower bits, your conversion is less accurate than it could be.
Your code 00111111011110110000000000000000 represents 0.98046875
The code 00111111011110110001010110110101 represents about 0.98079997...

Maybe 9 bits is good enough for your application, but I wonder why you are going through the extra effort of using a standard floating point format, and then throwing away most of its accuracy.
 

OK , I GOT IT. My application is DCT. I am using this standard floating point representation of the cosine co-efficients. I thought this representation will be more accurate than other kind of representations
 

I have done a project on DCT too. But i found, using fixed point notation to represent fractions is more efficient for FPGAs since DCT isnt very sensitive to accuracy issues.
 

is it mandatory that we should calculate the value for all 23 bits in the significand

Using the single-precision floating point format, the mantissa is a 24-bit value (23+1), representing about seven decimal digits (2exp24 = 1.68·10exp7). By using a 9-bit mantissa, you only get 2 decimal digits of precision (2exp9 = 5.12·10exp2)
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top