From 9b538f3783415e7172a5372800ea965dc911b7ba Mon Sep 17 00:00:00 2001 From: Krishna Vedala Date: Sat, 2 May 2020 18:04:58 -0400 Subject: [PATCH] ignore non numeric characters when creating large_number from a string --- others/large_number.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/others/large_number.h b/others/large_number.h index 8a6afcaa4..8c7f688d0 100644 --- a/others/large_number.h +++ b/others/large_number.h @@ -48,7 +48,11 @@ public: large_number(const char *number_str) /**< initializer from a string */ { for (size_t i = strlen(number_str); i > 0; i--) - _digits.push_back(number_str[i - 1] - '0'); + { + unsigned char a = number_str[i - 1] - '0'; + if (a >= 0 && a <= 9) + _digits.push_back(a); + } } /**