Kaynağa Gözat

allowed '-' in double

Wolfgang Ortmann 9 yıl önce
ebeveyn
işleme
f6116b6645
1 değiştirilmiş dosya ile 3 ekleme ve 3 silme
  1. 3 3
      src/stringtools.cpp

+ 3 - 3
src/stringtools.cpp

@@ -126,10 +126,10 @@ long int getLongInt(const string& s, unsigned int& i)
 
 
 double getDouble(const string& s, unsigned int& i)
 double getDouble(const string& s, unsigned int& i)
 {
 {
-  if (!isdigit(s[i]))
-    throw Exception("getLongInt", "digit expected");
+  if (!isdigit(s[i])||s[i]=='-')
+    throw Exception("getDouble", "digit expected");
   string is;
   string is;
-  while (i < s.size() && (isdigit(s[i]) || s[i]=='.' || s[i]=='e' || s[i]=='E'))
+  while (i < s.size() && (isdigit(s[i]) || s[i]=='-' || s[i]=='.' || s[i]=='e' || s[i]=='E'))
     {
     {
       is += s[i];
       is += s[i];
       ++i;
       ++i;