patch_todouble

This commit is contained in:
Leo Firmin 2026-02-02 21:37:50 +01:00
parent 5a5528db10
commit 4f53bd79a0
4 changed files with 8 additions and 4 deletions

Binary file not shown.

View File

@ -104,8 +104,6 @@ bool ScalarConverter::isDouble(const std::string& input)
i++;
}
double d = atof(input.c_str());
std::cout << "DEBUG double: d = " << d << std::endl; // ← AJOUTE
std::cout << "DEBUG isinf: " << std::isinf(d) << std::endl; // ← AJOUTE
if (std::isinf(d))
return false;
@ -171,6 +169,7 @@ void ScalarConverter::toInt(const std::string &input)
void ScalarConverter::toFloat(const std::string &input)
{
float f = static_cast<float>(atof(input.c_str()));
if (f >= std::numeric_limits<char>::min() && f <= std::numeric_limits<char>::max())
{
char c = static_cast<char>(f);
@ -206,7 +205,11 @@ void ScalarConverter::toDouble(const std::string &input)
std::cout << "int: \t" << static_cast<int>(d) << std::endl;
else
std::cout << "int: \timpossible" << std::endl;
std::cout << "float: \t" << std::fixed << std::setprecision(1) << static_cast<float>(d) << "f" << std::endl;
float f = static_cast<float>(d);
if (std::isinf(f))
std::cout << "float: \timpossible" << std::endl;
else
std::cout << "float: \t" << std::fixed << std::setprecision(1) << f << "f" << std::endl;
std::cout << "double: \t" << d << std::endl;
}
@ -243,3 +246,4 @@ void ScalarConverter::convert(const std::string &input)
else
std::cout <<"Invalid input." << std::endl;
}

Binary file not shown.

Binary file not shown.