aboutsummaryrefslogtreecommitdiff
path: root/src/utils/string.c
diff options
context:
space:
mode:
authorA404M <ahmadmahmoudiprogrammer@gmail.com>2025-05-26 01:24:56 +0330
committerA404M <ahmadmahmoudiprogrammer@gmail.com>2025-05-26 01:24:56 +0330
commitafa78451df1e9fb2810d4ae8cb697b1b2071ff9c (patch)
tree9b0ad12b58522cc0f99832253b1948fdebc1158c /src/utils/string.c
parente55d45bac0bbd3039118bffa7e6aaf01c04b991a (diff)
add shift
Diffstat (limited to 'src/utils/string.c')
-rw-r--r--src/utils/string.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/utils/string.c b/src/utils/string.c
index d05f0ec..1932d89 100644
--- a/src/utils/string.c
+++ b/src/utils/string.c
@@ -56,6 +56,33 @@ u64 decimalToU64(char const *str_begin, char const *str_end, bool *success) {
return result;
}
+u64 hexToU64(char const *str_begin, char const *str_end, bool *success) {
+ u64 result = 0;
+
+ if (str_end - str_begin > 16) {
+ *success = false;
+ return 0;
+ }
+
+ while (str_begin < str_end) {
+ result *= 16;
+ if ('0' <= *str_begin && *str_begin <= '9') {
+ result += *str_begin - '0';
+ } else if ('A' <= *str_begin && *str_begin <= 'F') {
+ result += *str_begin - 'A' + 10;
+ } else if ('a' <= *str_begin && *str_begin <= 'f') {
+ result += *str_begin - 'a' + 10;
+ } else {
+ *success = false;
+ return 0;
+ }
+ str_begin += 1;
+ }
+
+ *success = true;
+ return result;
+}
+
f128 numberToFloat(char const *str_begin, char const *str_end, bool *success) {
f128 left = 0;
f128 right = 0;