forked from rileym65/Basic-02
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgethex.c
More file actions
26 lines (23 loc) · 979 Bytes
/
Copy pathgethex.c
File metadata and controls
26 lines (23 loc) · 979 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*
*******************************************************************
*** This software is copyright 2021 by Michael H Riley ***
*** You have permission to use, modify, copy, and distribute ***
*** this software so long as this copyright notice is retained. ***
*** This software may not be used in commercial applications ***
*** without express written permission from the author. ***
*******************************************************************
*/
#include "header.h"
word getHex(char* line) {
word number;
number = 0;
while ((*line >= '0' && *line <= '9') ||
(*line >= 'a' && *line <= 'f') ||
(*line >= 'A' && *line <= 'F')) {
if (*line >= '0' && *line <= '9') number = (number << 4) + (*line - '0');
if (*line >= 'a' && *line <= 'f') number = (number << 4) + (*line - 'a') + 10;
if (*line >= 'A' && *line <= 'F') number = (number << 4) + (*line - 'A') + 10;
line++;
}
return number;
}