mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 14:12:16 +03:00
Проверка дробей и отрицательных чисел
This commit is contained in:
@@ -26,7 +26,9 @@ size_t itemsCount2(String str, const String& separator);
|
||||
|
||||
size_t itemsCount(String& str, const char* delim);
|
||||
|
||||
boolean isDigitStr(const String&);
|
||||
boolean isDigitStr(const String& str);
|
||||
|
||||
boolean isDigitDotCommaStr(const String& str);
|
||||
|
||||
String prettyBytes(size_t size);
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
void testsPerform() {
|
||||
Serial.println("====some tests section====");
|
||||
|
||||
//Serial.println(isDigitDotCommaStr("-12552.5555"));
|
||||
|
||||
//String str = "Geeks for Geeks ";
|
||||
//
|
||||
//Serial.println(itemsCount2(str, " "));
|
||||
|
||||
@@ -114,6 +114,16 @@ boolean isDigitStr(const String& str) {
|
||||
return str.length();
|
||||
}
|
||||
|
||||
boolean isDigitDotCommaStr(const String& str) {
|
||||
for (size_t i = 0; i < str.length(); i++) {
|
||||
char latter = str.charAt(i);
|
||||
if (!isDigit(latter) && latter != '.' && latter != '-') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
String prettyBytes(size_t size) {
|
||||
if (size < 1024)
|
||||
return String(size) + "b";
|
||||
|
||||
Reference in New Issue
Block a user