Mam takie problem że nie chce mi się w double wyświetlić liczna 800.00 mój kod wygląda tak:
#include "my_file.h"
#include <iostream>
#include <fstream>
#include <iomanip>
#include <stdexcept>
int main()
{
my_file file( "dane.txt" );
if ( file.is_file_opened() )
{
std::cerr << "Plik nie istnieje" << std::endl;
// return 1;
}
if ( file.is_file_empty() )
{
std::cerr << "Plik jest pusty" << std::endl;
// return 1;
}
std::string mm = file.add_budget() ;
std::cout << "budrzet ma : " << mm << std::endl;
try
{
double budget = std::stod( file.add_budget() );
}
catch ( std::invalid_argument)
{
std::cerr << "Dane w pliku nie są liczbami" << std::endl;
}
std::cout << "budrzet na starcie wynosi: " << std::setprecision(2) << budget << std::endl;
return 0;
}
Wydaje mi się że powinno się pojawić 800.00. Co dziwne to np. 800.22 już mi się poprawnie wyświetla. Czy to oznacza że funkcja std::setprecision() omija nie potrzebne zera bo i tak te zera nic na razie nie zmieniają?