Bc and dc calculator in Windows

The bc and dc software, is more than just a command line calculator — it is an arbitrary precision numeric processing language, also available as Free and Open Source Software (FOSS). Here we provide GNU bc and dc binaries for Windows.

2017-08-06

There are two modern FOSS implementations of bc and dc, that we are aware of: GNU bc and OpenBSD bc by Otto Moerbeek. If you use some GNU/Linux or BSD-style Operating System (OS), most likely bc is already installed on your computer. For those who use Windows operating system, we have built recent version of GNU bc and dc for Windows.

Using bc

Apparently both bc and dc are POSIX specified, but the more intuitive and more widely used program is bc, since it has C-like syntax. The dc program has Reverse Polish Notation (RPN) and is not very popular. A common way to use bc, is to start it in interactive mode, often with -l option, and then type away arithmetic expressions:

$ bc -l
bc 1.07.1
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006, 2008, 2012-2017 Free Software
 Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
8 + 19 / 7
10.71428571428571428571
abc = 2.667 * (3.53 + 11)
abc
38.75151
30 - abc
-8.75151

In order to exit bc's own command prompt, you can either use its quit command or press Ctrl+D.

Bc can also be used non interactively. That is helpful in shell scripting. For example, you could pipe the output of other commands through bc:

$ export MYVAR=2.508
$ echo "(23 + 1) / ${MYVAR}" | bc -l
9.56937799043062200956

More information about GNU bc is available in its online manual. Accordingly there is an online manual for GNU dc as well.

Bc and dc for Windows

You can download bc-1.07.1-win32-embedeo-02.zip file (~135KB). It contains our pre-built binaries of GNU bc and dc that can run on Windows directly. We strongly encourage you to read our disclaimer below, as well as GNU bc and dc license, which includes their disclaimer. Then you can unzip the file and add the location of its bin subdirectory to your PATH variable.

Using bc under Windows in its interactive mode is quite similar to the example above. If you are going to use bc in non interactive mode, perhaps, you will find helpful the following examples of Windows command line usage.

D:\test\bc>set MYVAR=2048

D:\test\bc>echo %MYVAR%
2048

D:\test\bc>echo sqrt (%MYVAR% / 2)  | bc -l
32.00000000000000000000
D:\test\bc>echo 100 + 22 / 7 > tmp.txt

D:\test\bc>type tmp.txt
100 + 22 / 7

D:\test\bc>bc -l < tmp.txt
103.14285714285714285714

If you want to build GNU bc from sources, then you can download the source code from a GNU mirror (the best way), or the main GNU ftp server: http://ftp.gnu.org/gnu/bc/ (via HTTP) or ftp://ftp.gnu.org/gnu/bc/ (via FTP). Alternatively, you can download our copy of bc-1.07.1.tar.gz file (~420KB). Our patch bc-1.07.1-embedeo-02.patch is intended for that particular 1.07.1 version. Our patch is public domain.

We would like to thank all the authors and contributors of GNU bc and dc, GNU Compiler Collection (GCC), MinGW and MSYS!

Alternatives

If bc is not enough for your needs, then you may wish to consider also some other FOSS programs for arbitrary precision numeric processing:

  • GNU octave is a scientific programming language, which is able to replace Matlab in most cases, or at least any use cases that we have at Embedeo.
  • Calc is another C-style arbitrary precision calculator, very similar to bc, but with many more builtin functions.

Disclaimer

WE DISCLAIM ALL WARRANTIES WITH REGARD TO ANY SOFTWARE IN SOURCE OR BINARY FORM, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.

All trademarks and registered trademarks appearing on this page are the property of their respective owners.

Copyright (C) 2017 embedeo.com Terms of use and legal disclaimer