2014 dxdy logo

Научный форум dxdy

Математика, Физика, Computer Science, Machine Learning, LaTeX, Механика и Техника, Химия,
Биология и Медицина, Экономика и Финансовая Математика, Гуманитарные науки




На страницу Пред.  1, 2
 
 Re: C++ _atold()
Сообщение10.02.2016, 13:20 
Аватара пользователя
Joe Black в сообщении #1098362 писал(а):
Страница 308 упражнение 7
Понятно.

Если у вас есть доступ к C++11, то в нём предусмотрена стандартная функция stold
ISO/IEC 14882:2011 писал(а):
float stof(const string& str, size_t *idx = 0);
double stod(const string& str, size_t *idx = 0);
long double stold(const string& str, size_t *idx = 0);

  1. Effects: the first two functions call strtod(str.c_str(), ptr) and the third function calls strtold(str.c_str(), ptr). Each function returns the converted result, if any. The argument ptr designates a pointer to an object internal to the function that is used to determine what to store at *idx. If the function does not throw an exception and idx != 0, the function stores in *idx the index of the first unconverted element of str.
  2. Returns: The converted result.
  3. Throws: invalid_argument if strtod or strtold reports that no conversion could be performed.
    Throws out_of_range if strtod or strtold sets errno to ERANGE.
Так как согласно упражнению, всё же, должен использоваться тип long double.

 
 
 [ Сообщений: 16 ]  На страницу Пред.  1, 2


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group