patch_todouble
This commit is contained in:
parent
5a5528db10
commit
4f53bd79a0
Binary file not shown.
|
|
@ -104,8 +104,6 @@ bool ScalarConverter::isDouble(const std::string& input)
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
double d = atof(input.c_str());
|
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))
|
if (std::isinf(d))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -171,6 +169,7 @@ void ScalarConverter::toInt(const std::string &input)
|
||||||
void ScalarConverter::toFloat(const std::string &input)
|
void ScalarConverter::toFloat(const std::string &input)
|
||||||
{
|
{
|
||||||
float f = static_cast<float>(atof(input.c_str()));
|
float f = static_cast<float>(atof(input.c_str()));
|
||||||
|
|
||||||
if (f >= std::numeric_limits<char>::min() && f <= std::numeric_limits<char>::max())
|
if (f >= std::numeric_limits<char>::min() && f <= std::numeric_limits<char>::max())
|
||||||
{
|
{
|
||||||
char c = static_cast<char>(f);
|
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;
|
std::cout << "int: \t" << static_cast<int>(d) << std::endl;
|
||||||
else
|
else
|
||||||
std::cout << "int: \timpossible" << std::endl;
|
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;
|
std::cout << "double: \t" << d << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -243,3 +246,4 @@ void ScalarConverter::convert(const std::string &input)
|
||||||
else
|
else
|
||||||
std::cout <<"Invalid input." << std::endl;
|
std::cout <<"Invalid input." << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
BIN
ex00/obj/Main.o
BIN
ex00/obj/Main.o
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue