1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-11-12 16:39:04 -08:00
rc/sh/arith

22 lines
541 B
Text
Raw Normal View History

#!/usr/bin/env zsh
# YES_ZSH YES_BASH YES_DASH YES_ASH
# 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
arith() { ### @-
### perform arithmetic using the shell and display the result.
2021-08-01 07:33:28 -07:00
### see also [`hex`](#hex) and [`bin`](#bin).
2021-08-01 09:45:19 -07:00
### this example requires zsh:
2021-08-01 07:33:28 -07:00
###
### ```
### % db=6
### % noglob arith 10**(db/20.)
### 1.9952623149688795
### ```
# <<<"$(($@))"
printf "%s\n" "$(($@))"
2021-07-29 00:37:35 -07:00
}
[ -n "${preload+-}" ] || arith "$@"