作者jlovet ( )
看板MacDev
標題Re: [問題] 請問關於科學符號?
時間Sat Sep 4 23:35:22 2010
※ 引述《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
1F:→ valda:在objective c的環境下我該怎麼做呢?感謝 09/05 00:39
2F:→ jlovet:看你是怎麼輸出的,最簡單的方法是,用stringstream轉成字串 09/05 00:52
3F:→ valda:只是要將double EX:1E10->1000000000 然後轉給NSstring 09/05 00:55
4F:→ uranusjr:或者用 NSString 的 xxxWithFormat: methods, 然後用 %f 09/05 01:04