I know that double has double the amount of memory as a float value but I was wondering if anyone can dig deeper to give me an easy to comprehend explanation. I am working on a program but for some reason a one decimal place value float doesn't work whereas double does. Why?
When you change the double maxSpecificGrowthRate, to float maxSpecificGrowthRate. It runs as though it passed through my if statement. When I print out the value it shows as 0.2 which should have been stopped by the if statement.
Code:
#include "stdafx.h
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <fstream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
float maxDilutionRate;
double maxSpecificGrowthRate;
float saturationConstant;
int substrateConcentration;
cout << "Enter maximum specific growth rate (per hour): ";
cin >> maxSpecificGrowthRate;
if (maxSpecificGrowthRate <= 0.2 || maxSpecificGrowthRate >= 0.7)
{
cout << "The maximum specific growth rate is not between 0.2-0.7 g/L. Terminating program..." << endl;
system("pause");
return 0;
}
system("pause");
return 0;
}