diff --git a/include/real.cpp b/include/real.cpp index ba6d914d7..180a63743 100755 --- a/include/real.cpp +++ b/include/real.cpp @@ -79,6 +79,26 @@ bool real::is_real (const char *s) return ok; } +bool real::is_natural (const char *s) +{ + bool ok = s && *s != '\0'; + if (ok) + { + while (*s == ' ') + s++; // Remove leading spaces before + + if (*s) + { + while (isdigit(*s)) + s++; + ok = *s == '\0'; + } + else ok = FALSE; + + } + return ok; +} + real::real (const char *s) { if (s) diff --git a/include/real.h b/include/real.h index 5a90711fd..839cb57ba 100755 --- a/include/real.h +++ b/include/real.h @@ -34,6 +34,7 @@ public: static char* eng2ita(char* s); static char* ita2eng(const char* s); static bool is_real(const char* n); + static bool is_natural(const char* n); // @FPUB DEC* ptr() const { return (DEC*)&_dec; }