| Author |
Message |
quer
Joined: 17 Nov 2007 Posts: 15
|
20 Mar 2009 18:07 signed decimal |
|
|
|
|
please give me an example on how to do it..
|
|
| Back to top |
|
 |
FvM
Joined: 22 Jan 2008 Posts: 5161 Helped: 767 Location: Bochum, Germany
|
20 Mar 2009 18:15 unsigned decimal |
|
|
|
|
| The question isn't clear. Only positive numbers can be converted - without changing anything, just copy respectively typecast it. The bit pattern is identical.
|
|
| Back to top |
|
 |
quer
Joined: 17 Nov 2007 Posts: 15
|
20 Mar 2009 18:27 convert signed to unsigned |
|
|
|
|
| sorry i mean how to convert numbers like -.023 (decimal) to unsigned decimal (ranging from 0 t 255).. actually i don't know if there is such process...
|
|
| Back to top |
|
 |
Aya2002
Joined: 12 Dec 2006 Posts: 1409 Helped: 254 Location: Iraq
|
20 Mar 2009 18:30 convert unsigned to signed |
|
|
|
|
| i need it also but in matlab
|
|
| Back to top |
|
 |
quer
Joined: 17 Nov 2007 Posts: 15
|
20 Mar 2009 19:00 converting signed to unsigned |
|
|
|
|
| Aya2002 wrote: |
| i need it also but in matlab |
yeah we are having the same problem
|
|
| Back to top |
|
 |
Google AdSense

|
20 Mar 2009 19:00 Ads |
|
|
|
|
|
|
| Back to top |
|
 |
FvM
Joined: 22 Jan 2008 Posts: 5161 Helped: 767 Location: Bochum, Germany
|
20 Mar 2009 19:37 unsigned to signed converter |
|
|
|
|
Two comments.
1. If an 8-bit integer (0..255) is representing a negative number like -0.023, it's not unsigned. It's e.g. a fixed point or fractional signed number. Of course you can display it as an unsigned, but it still contains a sign information.
2. You have to know the scaling of your target number format respectively the numeric range represented by it, than a conversion is easy. 0..255 may e.g. represent -1..+1. You can read it then as 2's complement signed value with a power of 2 scaling factor. (-128..127 *1/128). In this case, -0.023 converts to -3 respectively 253 or 0xfd when displayed as unsigned.
|
|
| Back to top |
|
 |
Aya2002
Joined: 12 Dec 2006 Posts: 1409 Helped: 254 Location: Iraq
|
20 Mar 2009 19:40 decimal to unsigned |
|
|
|
|
| explain more please with another example
|
|
| Back to top |
|
 |
FvM
Joined: 22 Jan 2008 Posts: 5161 Helped: 767 Location: Bochum, Germany
|
21 Mar 2009 0:18 signed to unsigned convert |
|
|
|
|
| I tried to give a sense to an unclear question by suggesting a number format and defining a range. I'd rather like to hear a complete question first.
|
|
| Back to top |
|
 |