1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-06-26 09:07:12 -07:00
rc/sh/arith

25 lines
547 B
Plaintext
Raw Normal View History

#!/usr/bin/env zsh
2021-07-29 00:37:35 -07:00
# YES_ZSH
# YES_BASH
# YES_DASH
2021-09-23 06:48:05 -07:00
# 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 "$@"