Re: sprintf x signed values
"Ricardo Raupp" <[email protected]> Sat, 26 Apr 2008 16:41:16 -0300
| Newsgroups | gmane.comp.hardware.motorola.microcontrollers.coldfire |
|---|---|
| Message-ID | <00e701c8a7d5$7e626770$c705050a@ricardo> |
People
From Freescale forum I got a help wich explained my problem.
Follow below the last chat ...
Thanks everybody !!!
Daniel
You were rigth...my char was (some spirit did it..I don´t remember...) defined as unsigned char by default.
Follow attached the CW screeshoot where it was set...
After I reset it...I got happy again ...
Now it is working fine...
Saturday nigth will ne good ....
Thanks for your attention!!!!!!
Ricardo Raupp
----- Original Message -----
From: Ricardo Raupp
To: Ricardo
Sent: Saturday, April 26, 2008 12:52 PM
Subject: [ColdFire] sprintf x signed values
Hi people
I´m working with 52235 and I´m trying to print a negative value for a char (int8) wich is -2, by using sprintf function, but the output is "254".
I did:
{
...
int8 sdata_8;
sdata_8=-2;
sprintf(lcd_controller.text_data_array,"%hi.", sdata_8);
...
}
I did the same experience using int16 and so I had success..
Is there some special care to use sprintf with char?
By the way, how can copy a negative value of a int8 to a int16?
I tryied:
sdata_16=sdata_8; and I got the calue 254 for sdata_16 ..and not -02 ...
Thanks guys ...
Ricardo Raupp
__________ NOD32 3056 (20080426) Information __________
This message was checked by NOD32 antivirus system.
http://www.eset.com
[email protected] Send a post to the list. [email protected] Join the list. [email protected] Join the list in digest mode. [email protected] Leave the list.
signed_selection.doc
(application/msword, 45 KB) - not displayed