search for: hex_to_bin

Displaying 6 results from an estimated 6 matches for "hex_to_bin".

2015 Aug 31
1
[OT] GNU bc base conversion
...bummer given that behavior. :-/ I suppose that depends on what you're trying to accomplish. Most conversions you can do entirely within bash, if that's your goal. function dec_to_hex () { printf '%x\n' $1; } function hex_to_dec() { printf '%d\n' $(( 16#$1 )); } function hex_to_bin() { echo 'obase=2;' $(( 16#$1 )) | bc; } $ dec_to_hex 10 a $ hex_to_dec a 10 $ hex_to_bin a 1010
2015 Aug 28
3
[OT] GNU bc base conversion
On Aug 28, 2015, at 9:50 AM, Gordon Messmer <gordon.messmer at gmail.com> wrote: > > On 08/28/2015 07:15 AM, Mike - st257 wrote: >> Thoughts as to why my BC functions aren't properly converting between bases? >> >> Decimal to binary or hex works fine, but not binary or hex to decimal and >> so forth. > > I'm not an expert in bc, so I might be
2017 May 04
0
[PATCH v1] ACPI: Switch to use generic UUID API
...if (str[i] != '-') > - return AE_BAD_PARAMETER; > - } else if (!isxdigit(str[i])) > - return AE_BAD_PARAMETER; > - } > - for (i = 0; i < 16; i++) { > - uuid[i] = hex_to_bin(str[opc_map_to_uuid[i]]) << 4; > - uuid[i] |= hex_to_bin(str[opc_map_to_uuid[i] + 1]); > - } > - return AE_OK; > -} > -EXPORT_SYMBOL_GPL(acpi_str_to_uuid); > - > acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context) >...
2017 May 04
12
[PATCH v1] ACPI: Switch to use generic UUID API
...trlen(str) != 36) - return AE_BAD_PARAMETER; - for (i = 0; i < 36; i++) { - if (i == 8 || i == 13 || i == 18 || i == 23) { - if (str[i] != '-') - return AE_BAD_PARAMETER; - } else if (!isxdigit(str[i])) - return AE_BAD_PARAMETER; - } - for (i = 0; i < 16; i++) { - uuid[i] = hex_to_bin(str[opc_map_to_uuid[i]]) << 4; - uuid[i] |= hex_to_bin(str[opc_map_to_uuid[i] + 1]); - } - return AE_OK; -} -EXPORT_SYMBOL_GPL(acpi_str_to_uuid); - acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context) { acpi_status status; struct acpi_object_list input; unio...
2012 Apr 20
1
[PATCH] multiqueue: a hodge podge of things
...quot;statistics", .attrs = fc_statistics_attrs, }; /* Host Vport Attributes */ static int fc_parse_wwn(const char *ns, u64 *nm) { unsigned int i, j; u8 wwn[8]; memset(wwn, 0, sizeof(wwn)); /* Validate and store the new name */ for (i=0, j=0; i < 16; i++) { int value; value = hex_to_bin(*ns++); if (value >= 0) j = (j << 4) | value; else return -EINVAL; if (i % 2) { wwn[i/2] = j & 0xff; j = 0; } } *nm = wwn_to_u64(wwn); return 0; } /* * "Short-cut" sysfs variable to create a new vport on a FC Host. * Input is a string of the form...
2012 Apr 20
1
[PATCH] multiqueue: a hodge podge of things
...quot;statistics", .attrs = fc_statistics_attrs, }; /* Host Vport Attributes */ static int fc_parse_wwn(const char *ns, u64 *nm) { unsigned int i, j; u8 wwn[8]; memset(wwn, 0, sizeof(wwn)); /* Validate and store the new name */ for (i=0, j=0; i < 16; i++) { int value; value = hex_to_bin(*ns++); if (value >= 0) j = (j << 4) | value; else return -EINVAL; if (i % 2) { wwn[i/2] = j & 0xff; j = 0; } } *nm = wwn_to_u64(wwn); return 0; } /* * "Short-cut" sysfs variable to create a new vport on a FC Host. * Input is a string of the form...