Skip to content

Awk script based calculator with floating point support

License

Notifications You must be signed in to change notification settings

awk-utilities/calc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Calc

Awk script based calculator with floating point support

Byte size of Calc Open Issues Open Pull Requests Latest commits



Requirements

This project was tested with GNU flavored Awk, AKA gawk; before opening new Issues please ensure that version 4.1.4 or greater is installed...

  • Arch based Operating Systems
sudo packman -Syy

sudo packman -S gawk
  • Debian derived Distributions
sudo apt-get update

sudo apt-get install gawk

Quick Start

Clone this project...

Linux/MacOS

mkdir -vp ~/git/hub/awk-utilities

cd ~/git/hub/awk-utilities

git clone git@github.com:awk-utilities/calc.git

Install via linked-install.sh script...

cd ~/git/hub/awk-utilities/calc

./linked-install.sh

Usage

Linux based distributions with MAwk, GAwk, and/or Awk installed generally may run Awk scripts directly, eg...

calc.awk <<<'2 + 2'
#> 4

... however, some systems do not have the Awk executable linked to /usr/bin/awk file path, in such cases Awk scripts must be invoked via...

awk -f ./calc.awk <<<'4.2 - 8'
#> -3.8

Because this script is line orientated, multiple separate/independent calculations may be preformed, and built-in Awk functions may be called, eg...

calc.awk <<EOF
6^2
sqrt(81)
EOF
#> 36
#> 9

... or file(s) may be used as script input...

equations.txt

7**7
40+2
99/11
calc.awk equations.txt
#> 823543
#> 42
#> 9

Notes

Warning large numbers will overflow Awk, at which point inf is returned, eg...

calc <<<'2**1024'
#> inf

... Additionally mixing inf with -inf will often result in -nan, eg...

calc <<<'(2**1024) - (2**1024)'
#> -nan

Contributing

Options for contributing to calc and awk-utilities


Forking

Start making a Fork of this repository to an account that you have write permissions for.

  • Add remote for fork URL. The URL syntax is git@github.com:<NAME>/<REPO>.git...
cd ~/git/hub/awk-utilities/calc

git remote add fork git@github.com:<NAME>/calc.git
  • Commit your changes and push to your fork, eg. to fix an issue...
cd ~/git/hub/awk-utilities/calc


git commit -F- <<'EOF'
:bug: Fixes #42 Issue


**Edits**


- `<SCRIPT-NAME>` script, fixes some bug reported in issue
EOF


git push fork main

Note, the -u option may be used to set fork as the default remote, eg. git push fork main however, this will also default the fork remote for pulling from too! Meaning that pulling updates from origin must be done explicitly, eg. git pull origin main

  • Then on GitHub submit a Pull Request through the Web-UI, the URL syntax is https://github.com/<NAME>/<REPO>/pull/new/<BRANCH>

Note; to decrease the chances of your Pull Request needing modifications before being accepted, please check the dot-github repository for detailed contributing guidelines.


Sponsor

Thanks for even considering it!

With sponsor__shields_io__liberapay you may sponsor awk-utilities on a repeating basis.

Regardless of if you're able to financially support projects such as calc that awk-utilities maintains, please consider sharing projects that are useful with others, because one of the goals of maintaining Open Source repositories is to provide value to the community.


Attribution


License

Awk script based calculator with floating point support
Copyright (C) 2020 S0AndS0

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, version 3 of the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.

For further details review full length version of AGPL-3.0 License.

About

Awk script based calculator with floating point support

Resources

License

Code of conduct

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published