Convert signed integer to a 16-bit hex number #2

  • Follow


I know there must be an easy way to do this, but I'm new to matlab and have not been able to figure it out and have tried searching for a solution without luck.

I need to convert a signed integer to a 16-bit sign-extended (2's complement) hex number for output to a file.

For example:

3 -> 0003
-3 -> FFFD

I've tried using dec2hex(), but it does not support negative number.  I've also tried playing around with a fi object but could not quite figure out how to make that work as I needed it to.

Any suggestions?

Thanks!
0
Reply Jordan 5/25/2010 3:39:24 PM

Oops, sorry ignore this post, accidental double post.

"Jordan " <jmcoreymv@hotmail.com> wrote in message <htgqvc$1e0$1@fred.mathworks.com>...
> I know there must be an easy way to do this, but I'm new to matlab and have not been able to figure it out and have tried searching for a solution without luck.
> 
> I need to convert a signed integer to a 16-bit sign-extended (2's complement) hex number for output to a file.
> 
> For example:
> 
> 3 -> 0003
> -3 -> FFFD
> 
> I've tried using dec2hex(), but it does not support negative number.  I've also tried playing around with a fi object but could not quite figure out how to make that work as I needed it to.
> 
> Any suggestions?
> 
> Thanks!
0
Reply Jordan 5/25/2010 3:47:20 PM


1 Replies
721 Views

(page loaded in 0.024 seconds)

Similiar Articles:













7/23/2012 6:17:02 PM


Reply: