| koren |
Дата 2.5.2010, 14:01 (ссылка)
  |   (голосов:1)
Загрузка ...
|
|
|
Шустрый

Профиль
Группа: Участник
Сообщений: 92
Регистрация: 7.11.2009
Репутация: 1 Всего: 2
|
| Код | string from_double_to_string(double num, char type_number, int precision_) { char *buf;
switch(type_number) { case 'f': { unsigned long int N=fabs(num); int count_integer=0; //подсчет количества цифр while ( N != 0 ) { N /= 10; count_integer++; } buf=new char[precision_+count_integer+3]; sprintf(buf,"%*.*f",0,precision_,num); break; } case 'g': { buf=new char[precision_+6]; sprintf(buf,"%*.*g",0,precision_,num); break; } case 'e': { unsigned long int N=fabs(num); int count_integer=0; //подсчет количества цифр while ( N != 0 ) { N /= 10; count_integer++; } buf=new char[precision_+count_integer+6]; sprintf(buf,"%*.*e",0,precision_,num); break; } } string temp(buf); delete buf; return temp; }
|
Проверьте!!!
|
|
|
|