Itoa conversion

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Itoa conversion

988件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cesimkaol on Sun May 27 04:32:59 MST 2012
Thank you Zero , it works , you are the best...
0 件の賞賛
返信
5 返答(返信)

969件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cesimkaol on Mon May 28 09:11:31 MST 2012
Thank you Zero , you are the best.
0 件の賞賛
返信

969件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Sun May 27 11:41:52 MST 2012
Yes, pointer cluelessness is no Code Red invention :eek:
0 件の賞賛
返信

969件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by frame on Sun May 27 10:59:46 MST 2012
That's not uC or RedLib specific, it plain C language - the difference between an aggregated data type, and a reference to it.
0 件の賞賛
返信

969件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ex-kayoda on Sun May 27 06:46:52 MST 2012

Quote:

[COLOR=Red] char temperature_string[33];[/COLOR]    //recommended string length

That's worst case (=base 2) string length :rolleyes:

For bases >=10 string length can be reduced to 12 :)

  = optional -sign (1)  +  32bit decimal value digits (10) + null-termination (1)
0 件の賞賛
返信

969件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Sun May 27 04:57:47 MST 2012
You are trying to store the ASCII string of an integer in 1 pointer to char :eek:

Nice compression trick, but unfortunately not working :rolleyes:

So use an array of >32 chars as mentioned in:

http://support.code-red-tech.com/CodeRedWiki/redlib_itoa

Sample:
float temperature = 1234.56;    //melting iron
[COLOR=Red]char temperature_string[33];[/COLOR]    //recommended string length

int main(void)
{
 volatile static int i = 0 ;
 while(1)
 {
  i++ ;
  itoa((int)(temperature*100),&temperature_string[0],10);//convert with decimals
 }
 return 0 ;
}
0 件の賞賛
返信