convert to negative floating number to hexa
smartshashi,
You can easily convert decimal fractions to hex using a calculator. Supporse you're working with 16 bit numbers.
Step 1: multiply the fraction by 65536 (2^16)
Step 2: Convert to hex. This is easy on a scientific calculator.
The result is a binary fraction with the MSB having a weight of .5, the 2nd MSB having a weight of .25, etc.
.
Example, convert 0.75 to hex
Step 1: 0.75 X 65536 = 49152
Step 2 convert to hex = C000 (.5 + .25)
.
For negative numbers, just take the 2's complement as you would for an integer. This is done by complementing all the bits and adding 1 (Throw away the carry, if any)
.
When you are done, of course, you must divide the result by 65536 to get the proper scaling.
Regards,
Kral