Re: [問題] 請問關於科學符號?

看板MacDev作者 ( )時間13年前 (2010/09/04 23:35), 編輯推噓0(004)
留言4則, 3人參與, 最新討論串2/3 (看更多)
※ 引述《valda (valda)》之銘言: : 大家好,請問個問題,若double超過一定的位數complier好像自動會轉成 : 科學符號,請問有辦法不讓他轉科學符號嗎?感謝 #include <iostream> #include <iomanip> using namespace std; using std::setprecision; int main(){ double d = 0.1; int i=0; for(int i=0;i<50;i++){ cout<<fixed<<setprecision(70)<<d<<endl; d=d/10; } d=0.1; for(int i=0;i<50;i++){ cout<<fixed<<setprecision(70)<<d<<endl; d=d*10; } return 0; } 關鍵字 iomanip cout<<fixed -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 211.74.187.51

09/05 00:39, , 1F
在objective c的環境下我該怎麼做呢?感謝
09/05 00:39, 1F

09/05 00:52, , 2F
看你是怎麼輸出的,最簡單的方法是,用stringstream轉成字串
09/05 00:52, 2F

09/05 00:55, , 3F
只是要將double EX:1E10->1000000000 然後轉給NSstring
09/05 00:55, 3F

09/05 01:04, , 4F
或者用 NSString 的 xxxWithFormat: methods, 然後用 %f
09/05 01:04, 4F
文章代碼(AID): #1CWcS-60 (MacDev)
文章代碼(AID): #1CWcS-60 (MacDev)