An implementation of Unix dc and POSIX bc with GNU and BSD extensions
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Gavin Howard 9b1e080cf3
Remove warnings from locale_install.sh
3 years ago
gen Change all of the license headers 3 years ago
include Fix Coverity Scan errors 3 years ago
locales Fix a mistake of mine, not skarnet's, in French translations 3 years ago
manuals Update the build manual 3 years ago
src Fix some style 3 years ago
tests Change all of the license headers 3 years ago
.gitignore Reduce work for the release script 3 years ago
.travis.yml Remove some useless testing in travis 3 years ago
LICENSE.md Tweak the license and README 4 years ago
Makefile.in Make installing and uninstalling locales work 3 years ago
NOTICE.md Update contributors list 3 years ago
README.md Remove use of uintptr_t 3 years ago
RELEASE.md Fix the RELEASE.md checklist 3 years ago
codecov.yml Add a codecov file 4 years ago
configure.sh Fix a bug in configure.sh options parsing 3 years ago
functions.sh Use pipe character instead of \n as temporary separator to delimit the place-holders. 3 years ago
install.sh Change all of the license headers 3 years ago
karatsuba.py Change all of the license headers 3 years ago
link.sh Change all of the license headers 3 years ago
locale_install.sh Remove warnings from locale_install.sh 3 years ago
locale_uninstall.sh Make installing and uninstalling locales work 3 years ago
release.sh Change all of the license headers 3 years ago
safe-install.sh Make install work for just dc 4 years ago

README.md

bc

Build Status codecov Coverity Scan Build Status

This is an implementation of the POSIX bc calculator that implements GNU bc extensions, as well as the period (.) extension for the BSD flavor of bc.

For more information, see this bc's full manual.

This bc also includes an implementation of dc in the same binary, accessible via a symbolic link, which implements all FreeBSD and GNU extensions. If a single dc binary is desired, bc can be copied and renamed to dc. The ! command is omitted; I believe this poses security concerns and that such functionality is unnecessary.

For more information, see the dc's full manual.

This bc is Free and Open Source Software (FOSS). It is offered under the BSD 2-clause License. Full license text may be found in the LICENSE.md file.

Prerequisites

This bc only requires a C99-compatible compiler and a (mostly) POSIX 2008-compatible system with the XSI (X/Open System Interfaces) option group.

Since POSIX 2008 with XSI requires the existence of a C99 compiler as c99, any POSIX and XSI-compatible system will have everything needed.

Systems that are known to work:

  • Linux
  • FreeBSD
  • OpenBSD
  • Mac OSX

Please submit bug reports if this bc does not build out of the box on any system besides Windows. If Windows binaries are needed, they can be found at xstatic.

Build

This bc should build unmodified on any POSIX-compliant system.

For more complex build requirements than the ones below, see the build manual.

Pre-built Binaries

It is possible to download pre-compiled binaries for a wide list of platforms, including Linux- and Windows-based systems, from xstatic. This link always points to the latest release of bc.

Default

For the default build with optimization, use the following commands in the root directory:

./configure.sh -O3
make

One Calculator

To only build bc, use the following commands:

./configure.sh --disable-dc
make

To only build dc, use the following commands:

./configure.sh --disable-bc
make

Debug

For debug builds, use the following commands in the root directory:

./configure.sh -g
make

Install

To install, use the following command:

make install

By default, bc and dc will be installed in /usr/local. For installing in other locations, see the build manual.

Status

This bc is robust.

It is well-tested, fuzzed, and fully standards-compliant (though not certified) with POSIX bc. The math has been tested with 40+ million random problems, so it is as correct as I can make it.

This bc can be used as a drop-in replacement for any existing bc. This bc is also compatible with MinGW toolchains, though history is not supported on Windows.

Performance

This bc has similar performance to GNU bc. It is slightly slower on certain operations and slightly faster on others. Full benchmark data are not yet available.

Algorithms

To see what algorithms this bc uses, see the algorithms manual.

Locales

Currently, this bc only has support for English (and US English) locales. Patches are welcome for translations; use the existing *.msg files in locales/ as a starting point.

Other Projects

Other projects based on this bc are:

  • busybox bc. The busybox maintainers have made their own changes, so any bugs in the busybox bc should be reported to them.

  • toybox bc. The maintainer has also made his own changes, so bugs in the toybox bc should be reported there.

Language

This bc is written in pure ISO C99, using POSIX 2008 APIs.

Commit Messages

This bc uses the commit message guidelines laid out in this blog post.

Semantic Versioning

This bc uses semantic versioning.

Contents

Items labeled with (maintainer use only) are not included in release source tarballs.

Files:

.gitignore           The git ignore file (maintainer use only).
.travis.yml          The Travis CI file (maintainer use only).
codecov.yml          The Codecov file (maintainer use only).
configure.sh         The configure script.
functions.sh         A script with functions used by other scripts.
install.sh           Install script.
karatsuba.py         Script to find the optimal Karatsuba number.
LICENSE.md           A Markdown form of the BSD 2-clause License.
link.sh              A script to link dc to bc.
locale_install.sh    A script to install locales, if desired.
locale_uninstall.sh  A script to uninstall locales.
Makefile.in          The Makefile template.
NOTICE.md            List of contributors and copyright owners.
RELEASE.md           A checklist for making a release (maintainer use only).
release.sh           A script to test for release (maintainer use only).
safe-install.sh      Safe install script from musl libc.

Folders:

gen      The bc math library, help texts, and code to generate C source.
include  All header files.
locales  Locale files, in .msg format. Patches welcome for translations.
manuals  Manuals for both programs.
src      All source code.
tests    All tests.