Skip to content

fermat-tech/winbc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

winbc

winbc is a GNU bc-compatible arbitrary-precision calculator for Windows and Linux, written in pure Go with no C dependencies.

It implements the full GNU bc language: arbitrary-precision decimal arithmetic, user-defined functions, arrays, control flow (if/else/while/for/break/continue/return), the print statement, the read() built-in, ibase/obase/scale special variables, and the -l math library (s, c, a, l, e, j functions).

Install

Download a binary (Windows or Linux)

Grab the latest release from the Releases page:

Platform File
Windows (amd64) winbc-windows-amd64.exe
Linux (amd64) winbc-linux-amd64

Rename / add to your PATH as desired.

go install

go install github.com/fermat-tech/winbc@latest

Requires Go 1.21 or later.

Usage

winbc [-hlwsqv] [long-options] [FILE ...]

  -h, --help       print this help and exit
  -l, --mathlib    load standard math library (sets scale=20)
  -w, --warn       warn about POSIX extensions used
  -s, --standard   process only POSIX bc language
  -q, --quiet      suppress welcome banner
  -v, --version    print version and exit

Files are processed in order before reading standard input. When stdin is a terminal, an interactive REPL prompt is shown.

Examples

# Interactive
winbc

# One-liner
echo "scale=10; 4*a(1)" | winbc -l     # pi to 10 decimal places

# Script file
winbc script.bc

Package documentation

Go Reference

The internal packages are documented on pkg.go.dev:

Package Description
lexer Tokenises bc source into a Token stream
parser Recursive-descent parser; produces AST nodes
interp Tree-walk interpreter / evaluator
num Arbitrary-precision decimal arithmetic

License

MIT — see LICENSE.md.

About

GNU bc-compatible arbitrary-precision calculator for Windows and Linux

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages