From 40ebcac0c81e385449f180dbbcaeacd96d676388 Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 7 Dec 1994 13:38:30 +0000 Subject: [PATCH] Aggiunto metodo is_natural git-svn-id: svn://10.65.10.50/trunk@740 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- include/real.cpp | 20 ++++++++++++++++++++ include/real.h | 1 + 2 files changed, 21 insertions(+) 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; }