From c9cbeced5b3f2bdd7407e29c0811e65954132540 Mon Sep 17 00:00:00 2001 From: Root THC Date: Tue, 24 Feb 2026 12:42:47 +0000 Subject: initial --- other/Kermit/lib/stoi16.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 other/Kermit/lib/stoi16.cpp (limited to 'other/Kermit/lib/stoi16.cpp') diff --git a/other/Kermit/lib/stoi16.cpp b/other/Kermit/lib/stoi16.cpp new file mode 100644 index 0000000..83aad59 --- /dev/null +++ b/other/Kermit/lib/stoi16.cpp @@ -0,0 +1,29 @@ +/* + * stoi16.cpp: + * written by palmers / teso + */ +#include + + unsigned int stoi16 (string x) + { + int num = 0, + base = 1, + z = x.length () - 1; + unsigned int y = 0; + + while (z >= 0) + { + if (x[z] <= '9' && x[z] >= '0') + num = x[z] - '0'; + if (x[z] <= 'f' && x[z] >= 'a') + num = x[z] - 'a' + 10; + if (x[z] <= 'F' && x[z] >= 'A') + num = x[z] - 'A' + 10; + + y += num * base; + base *= 16; + z--; + } + return y; + } + -- cgit v1.3