d06 ex00 all checks are ok
This commit is contained in:
@@ -1,23 +1,43 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <cctype> // isdigit()
|
||||
#include "color.h"
|
||||
#include "convert.h"
|
||||
|
||||
//Char toChar(str) {
|
||||
//
|
||||
//}
|
||||
|
||||
bool isFloat(std::string str) {
|
||||
if (str.length() == 4)
|
||||
size_t l;
|
||||
// std::string float_xtrem = MAX_FLOAT;
|
||||
|
||||
if (str[0] == '+' || str[0] == '-')
|
||||
str.erase(str.begin());
|
||||
// if (str.length() == 0 || str.length() > FLOAT_MAX_LENGTH)
|
||||
if (str.length() == 0)
|
||||
return false;
|
||||
if (!str.compare("inff") || !str.compare("nanf"))
|
||||
return true;
|
||||
return false;
|
||||
l = str.find_first_not_of("0123456789");
|
||||
if (l == std::string::npos || str[l] != '.')
|
||||
return false;
|
||||
str.erase(0,l + 1);
|
||||
l = str.find_first_not_of("0123456789");
|
||||
if (l == std::string::npos || str[l] != 'f')
|
||||
return false;
|
||||
|
||||
// to work, one should check the decimal and the integer part
|
||||
// str.erase(str.end() - 1);
|
||||
// if (str.length() < FLOAT_MAX_LENGTH)
|
||||
// return true;
|
||||
// if (str.compare(float_xtrem) > 0)
|
||||
// return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool checkFloat(std::string str) {
|
||||
|
||||
// float f;
|
||||
|
||||
std::cout << "in char\n";
|
||||
std::cout << "float\n";
|
||||
|
||||
if (!isFloat(str))
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user