mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-30 20:09:14 +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);
|
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);
|
String prettyBytes(size_t size);
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
void testsPerform() {
|
void testsPerform() {
|
||||||
Serial.println("====some tests section====");
|
Serial.println("====some tests section====");
|
||||||
|
|
||||||
|
//Serial.println(isDigitDotCommaStr("-12552.5555"));
|
||||||
|
|
||||||
//String str = "Geeks for Geeks ";
|
//String str = "Geeks for Geeks ";
|
||||||
//
|
//
|
||||||
//Serial.println(itemsCount2(str, " "));
|
//Serial.println(itemsCount2(str, " "));
|
||||||
|
|||||||
@@ -114,6 +114,16 @@ boolean isDigitStr(const String& str) {
|
|||||||
return str.length();
|
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) {
|
String prettyBytes(size_t size) {
|
||||||
if (size < 1024)
|
if (size < 1024)
|
||||||
return String(size) + "b";
|
return String(size) + "b";
|
||||||
|
|||||||
Reference in New Issue
Block a user