2020-12-29 08:38:07 -08:00
|
|
|
#!/usr/bin/env zsh
|
2021-07-29 00:37:35 -07:00
|
|
|
# YES_ZSH
|
2021-07-29 05:44:12 -07:00
|
|
|
# YES_BASH
|
|
|
|
# YES_DASH
|
|
|
|
|
|
|
|
# though technically compatible with other shells,
|
|
|
|
# extra functionality is through zsh's extended arithmetic functions.
|
2021-07-29 00:37:35 -07:00
|
|
|
|
2021-07-30 17:57:08 -07:00
|
|
|
hex() { ### @-
|
2021-08-01 07:33:28 -07:00
|
|
|
### perform arithmetic using the shell and display the result as
|
|
|
|
### an unsigned 32-bit integer in hexadecimal.
|
|
|
|
### see also [`arith`](#arith) and [`bin`](#bin).
|
|
|
|
###
|
|
|
|
### ```
|
|
|
|
### $ hex 0x221EA8-0x212020
|
|
|
|
### 0000FE88
|
|
|
|
### ```
|
2021-07-29 00:37:35 -07:00
|
|
|
printf "%08X\n" "$(($@))"
|
|
|
|
}
|
|
|
|
|
|
|
|
[ "${SOURCING:-0}" -gt 0 ] || hex "$@"
|