Hex computation helpers
More...
|
static byte | CharVal (char c) |
| Convert a hex digit to its corresponding decimal digit More...
|
|
static byte | CharValExpanded (char c) |
| Convert a single hex digit, into its expanded 2-digit form Eg. Interpret 0xA as 0xAA More...
|
|
static byte | CharVal (char c1, char c2) |
| Gets the byte val of 2 hex digits More...
|
|
static int | ToInt32 (string s) |
| Convert a string sequence of Hex to its decimal form More...
|
|
static long | ToInt64 (string s) |
| Convert a string sequence of Hex digits to its decimal form More...
|
|
static string | ToHex (long val, int minLen=0) |
| Convert an integer to its hex string More...
|
|
static string | ToHex (byte[] bytes) |
| Convert an array of bytes to its hex string More...
|
|
◆ CharVal() [1/2]
static byte pluginbase.Helpers.Hex.CharVal |
( |
char |
c | ) |
|
|
static |
Convert a hex digit to its corresponding decimal digit
- Returns
- The base10 digit.
- Parameters
-
Attribute: c & 0xff
;
42 return _charValues[c & 0xff];
◆ CharVal() [2/2]
static byte pluginbase.Helpers.Hex.CharVal |
( |
char |
c1, |
|
|
char |
c2 |
|
) |
| |
|
static |
Gets the byte val of 2 hex digits
- Returns
- The decimal value.
- Parameters
-
Attribute: c1 & 0xff] << 4 | _charValues[c2 & 0xff
);
65 return (byte)(_charValues[c1 & 0xff] << 4 | _charValues[c2 & 0xff]);
◆ CharValExpanded()
static byte pluginbase.Helpers.Hex.CharValExpanded |
( |
char |
c | ) |
|
|
static |
Convert a single hex digit, into its expanded 2-digit form Eg. Interpret 0xA as 0xAA
- Returns
- The decimal value
- Parameters
-
Attribute: c & 0xff
;
53 byte v = _charValues[c & 0xff];
54 return (byte)(v << 4 | v);
◆ ToHex() [1/2]
static string pluginbase.Helpers.Hex.ToHex |
( |
long |
val, |
|
|
int |
minLen = 0 |
|
) |
| |
|
static |
Convert an integer to its hex string
- Returns
- The hex.
- Parameters
-
val | Value. |
minLen | Minimum length. |
Attribute: val & 0xf
);
106 var s =
new StringBuilder();
109 s.Insert(0, _valueSymbol[val & 0xf]);
112 while (s.Length < minLen)
◆ ToHex() [2/2]
static string pluginbase.Helpers.Hex.ToHex |
( |
byte [] |
bytes | ) |
|
|
static |
Convert an array of bytes to its hex string
- Returns
- The hex.
- Parameters
-
Attribute: bytes[i] >> 4
); //Left bits
Attribute: bytes[i] & 0xf
); //Right bits
124 var s =
new StringBuilder();
125 for (
int i=0; i<bytes.Length; ++i)
127 s.Append(_valueSymbol[bytes[i] >> 4]);
128 s.Append(_valueSymbol[bytes[i] & 0xf]);
◆ ToInt32()
static int pluginbase.Helpers.Hex.ToInt32 |
( |
string |
s | ) |
|
|
static |
Convert a string sequence of Hex to its decimal form
- Returns
- Integer
- Parameters
-
Attribute: s[i] & 0xff
;
76 for (
int i=0; i<s.Length; ++i)
78 v = (v << 4) | _charValues[s[i] & 0xff];
◆ ToInt64()
static long pluginbase.Helpers.Hex.ToInt64 |
( |
string |
s | ) |
|
|
static |
Convert a string sequence of Hex digits to its decimal form
- Returns
- The int64.
- Parameters
-
Attribute: s[i] & 0xff
;
91 for (
int i=0; i<s.Length; ++i)
93 v = (v << 4) | _charValues[s[i] & 0xff];
The documentation for this class was generated from the following file: