If you are wondering which command line utility to use on your Mac Terminal to do arithmetic calculations such as addition, subtraction or multiplication then you can make use of bc - An arbitrary precision calculator language, it ships with your macOS.

Math Calculations on Mac Terminal
% man bc
bc(1) bc(1)
NAME
bc - An arbitrary precision calculator language
SYNTAX
bc [ -hlwsqv ] [long-options] [ file ... ]
VERSION
This man page documents GNU bc version 1.06.
DESCRIPTION
bc is a language that supports arbitrary precision numbers with inter-
active execution of statements. There are some similarities in the
syntax to the C programming language. A standard math library is
available by command line option. If requested, the math library is
defined before processing any files. bc starts by processing code from
all the files listed on the command line in the order listed. After
all files have been processed, bc reads from the standard input. All
code is executed as it is read. (If a file contains a command to halt
the processor, bc will never read from the standard input.)
Lets see some examples:
[email protected] ~ % bc
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
20+10+30
60
a=10
b=20
a+b
30
(a+b)*100
3000
(10/20)*100
0
You can see that the division came out to be incorrect, that because the result is truncated to an integer, you would need to use the -l option to work with floats.
-l, --mathlib
Define the standard math library
[email protected] ~ % bc -l
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
(10/20)*100
50.00000000000000000000
More Posts related to macOS,
- [macOS] How to search or view previous terminal command history
- [Eclipse] Locate Preferences in macOS
- macOS Big Sur compatible Macs List
- How to connect Airpods to Macbook Air or Pro?
- Display ls command file sizes in KB (kilobytes) MB (megabytes) or GB (gigabytes) [Linux/macOS]
- [macOS] Change homepage Macbook Safari Browser
- [Vi/Vim] How to move cursor to the start of a line
- bash: command not found error [macOS Terminal Linux, Unix or Windows]
- Set Python 3.8 as a default python version on macOS
- 30+ Zoom video communications application shortcuts for macOS
- say command macOS terminal examples
- Mac (macos) startup keyboard boot sequence combinations
- Cut, Copy and Paste keyboard commands on mac
More Posts:
- See actual SharePoint error exception modify web.config - SharePoint
- Rounded Images in Bootstrap framework - Bootstrap
- Java location in Mac OS X - Mac-OS-X
- SharePoint Designer Workflow error - Coercion Failed: Input cannot be null for this coercion - SharePoint
- How to enable line numbers in IntelliJ Android Studio for all files - Android-Studio
- incorrect line ending: found carriage return (\r) without corresponding newline (\n) - Android
- Failed to sync Gradle project Error:failed to find target android-23 - Android
- How to Add a horizontal line in Android Layout - Android
- No CPU ABI system image available for this target Error Android Virtual Device - Android
- Convert text to random case using Notepad++ - NotepadPlusPlus
- Java Code to check if Twitter app is installed on Android device - Android
- Android : Accidental Octal Lint Warning - Android
- Android activity main xml stuck loading - Android-Studio
- Android Eclipse This version of the rendering library is more recent than your version of ADT plug-in. Please update ADT plug-in - Android
- Google Search Hot Trends Screensaver for Mac OS X - Mac-OS-X