Skip to content

Commit 989d6c1

Browse files
committed
Value: Convert integers in string to long
1 parent 008b96a commit 989d6c1

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/scratch/value.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,19 @@ class LIBSCRATCHCPP_EXPORT Value : public ValueVariant
323323
}
324324

325325
bool ok;
326-
double d = stringToDouble(str, &ok);
326+
bool isLong = false;
327+
long l;
328+
double d;
329+
if ((str.find_first_of('.') == std::string::npos) && (str.find_first_of('e') == std::string::npos) && (str.find_first_of('E') == std::string::npos)) {
330+
l = stringToLong(str, &ok);
331+
isLong = true;
332+
} else
333+
d = stringToDouble(str, &ok);
327334
if (ok) {
328-
*this = d;
335+
if (isLong)
336+
*this = l;
337+
else
338+
*this = d;
329339
m_type = Type::Number;
330340
}
331341
}

0 commit comments

Comments
 (0)