- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

HI,

I learned from this link (http://stackoverflow.com/questions/15767758/correct-algorithm-to-convert-binary-floating-point-1101-...) that I could convert a binary (consists of both integer and fraction) to decimal values. I am wondering if this code can be used to check for negative value? I did try with a binary string of 11111101.11 and it gives the output of 253.75... I have two questions: What are the modifications I need to do in order to read a negative value? I know that I can do the bit shift (as below) to check if the msb is 1, if it is 1, I know it is negative value...`if (14bit_data & 0x2000) //if true, it is negative value`

The issue is, since it involves fraction part (but not only integer), it confused me a bit if the method still works... If the binary number is originally not in string format, is there any way I could convert it to string? The binary number is originally fed from a fpga block say, 14 bits, with msb as the sign bit, the following 6 bits are the magnitude for integer and the last 6 bits are the magnitude for fractional part. Any idea please? Thank you in advance
Link Copied

0 Replies

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page