🖥️bc

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the bc command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#  ██████╗  ██████╗
#  ██╔══██╗██╔════╝
#  ██████╔╝██║     
#  ██╔══██╗██║     
#  ██████╔╝╚██████╗
#  ╚═════╝  ╚═════╝

# Sorry, something messed up when I pasted this into Twitter.  x= should be:
# Also, numround is from num-utils either in your package manager or here: https://suso.suso.org/programs/num-utils/index.phtml …
x=$(bc -l <<<"150*$p*s(($p*2/360)*$i)"|numround)

BC_LINE_LENGTH=0 bc <<<"10^100" 
# Print out 10 to the 100th power, but use bc's environment variable BC_LINE_LENGTH=0 to print all on one line instead of wrapping.

# Convert a decimal number to octal, hexadecimal, binary, or anything
bc <<< 'obase=2;1234'
# Explanation: <<< word is here-string syntax, a variant of here-documents.

## Related one-liners

# Convert a decimal number to octal, hexadecimal, binary, or anything
echo 'obase=2;1234' | bc
# Explanation: 
    # bc is an arbitrary precision calculator language.
    # obase defines the conversion base for output numbers, in this example 2 (binary)
    # ; is a statement separator in bc
    # 1234 is the decimal number to convert
    # By piping the command to bc we get 1234 in binary format

# Convert a decimal number to octal, hexadecimal, binary, or anything
echo 'obase=2;1234' | bc
# Explanation: 
    # bc is an arbitrary precision calculator language.
    # obase defines the conversion base for output numbers, in this example 2 (binary)
    # ; is a statement separator in bc
    # 1234 is the decimal number to convert
    # By piping the command to bc we get 1234 in binary format

## Alternative one-liners: 

# Convert a decimal number to octal, hexadecimal, binary, or anything
bc <<< 'obase=2;1234'
# Explanation: <<< word is here-string syntax, a variant of here-documents.

# Calculate pi to an arbitrary number of decimal places
bc -l <<< "scale=1000; 4*a(1)"
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░