Re: 請問用C18要怎麼把浮點數轉換成字串呢?
|
||||
---|---|---|---|---|
資深會員
|
看看要不要用HI-TECH的PICC-18,C18我覺得有些難度…
HI-TECH的PICC-18可以讓您選擇是不是要使用float,很方便,至少我現在還沒有遇到問題. C30是給16Bits MCU用的Compiler,如果您的MCU是18系列的話,那看了手冊也沒用。 我的用法是(HI-TECH PICC18): extern void lcd_puts(char *s); void main(void) { char buff[17]; float v = 1.234 sprintf(buff, "%02.3f", v);//將v 轉成字串 lcd_puts(buff);//將字串交給LCD顯示 }
發表於: 2009/11/16 15:39
|
|||
我相信解決問題的方法不只一種,所以我在回答同好的問題時或者提出與主題不同的方案,
請不要以此做為攻擊的目標,畢竟我也只是想和大家討論如何解決問題而已… 解決問題最重要,..... |
||||
|
Re: 請問用C18要怎麼把浮點數轉換成字串呢?
|
||||
---|---|---|---|---|
資深會員
|
給z2490438, minki兩位:
版主 Ryang,已經講出答案了使用sprintf.
Include: stdio.h
發表於: 2009/11/16 10:45
|
|||
|
Re: 請問用C18要怎麼把浮點數轉換成字串呢?
|
||||
---|---|---|---|---|
初級會員
|
請問C30 ibearies User's Guide參考資料在哪裡呢?
我浮點數運算法都是用除的.. 所以算到9位數真的很痛苦,然後再判斷小數點 程式一大串,都快不知道怎麼寫了
發表於: 2009/11/16 8:39
|
|||
|
Re: 請問用C18要怎麼把浮點數轉換成字串呢?
|
||||
---|---|---|---|---|
初級會員
|
那...現在有辦法在C18上把浮點數轉換成字串嗎...?
發表於: 2009/11/15 22:19
|
|||
|
Re: 請問用C18要怎麼把浮點數轉換成字串呢?
|
||||
---|---|---|---|---|
版主
|
用 sprintf( ) 函數,將輸出的結果送到 RAM 裡。所以可以將要列印的浮點字串送到RAM後再轉送到LCD module 上。
楊細用法參考 C30 ibearies User's Guide。
發表於: 2007/8/20 16:45
|
|||
|
Re: 請問用C18要怎麼把浮點數轉換成字串呢?
|
||||
---|---|---|---|---|
中級會員
|
謝謝Ryang的回覆~
再請問一下C30的printf()函數 要怎麼使用呢? 我要把浮點數轉成字串秀在LCD上。 putrsLCD();//秀字串的Function
發表於: 2007/8/18 11:26
|
|||
|
Re: 請問用C18要怎麼把浮點數轉換成字串呢?
|
||||
---|---|---|---|---|
版主
|
C18 只提供 ltoa( ) 的函數,目前並沒有 ftoa( ) 的函數支援,且 C18 的 printf ( ) 也不支援浮點數的列印。浮點數轉成ASCII 是很不簡單的功能,目前只有 C30 的 printf( ) 函數有支援。
發表於: 2007/8/17 17:52
|
|||
|
請問用C18要怎麼把浮點數轉換成字串呢?
|
||||
---|---|---|---|---|
中級會員
|
在做資料處理時遇到這個問題
請問一下有適合的function可以用嗎? 還是有哪位兄台有處理過,可以教教我嗎? 謝謝大家~
發表於: 2007/8/17 10:37
|
|||
|