Lines Matching refs:bc
1 # `bc`
4 because of spam. If you need to report a bug with `bc`, email gavin at this site
11 This is an implementation of the [POSIX `bc` calculator][12] that implements
12 [GNU `bc`][1] extensions, as well as the period (`.`) extension for the BSD
13 flavor of `bc`.
15 For more information, see this `bc`'s full manual.
17 This `bc` also includes an implementation of `dc` in the same binary, accessible
19 standalone `dc` binary is desired, `bc` can be copied and renamed to `dc`.) The
25 This `bc` also provides `bc`'s math as a library with C bindings, called `bcl`.
31 This `bc` is Free and Open Source Software (FOSS). It is offered under the BSD
36 This `bc` only requires either:
56 In addition, there is compatibility code to make this `bc` work on Windows.
58 Please submit bug reports if this `bc` does not build out of the box on any
63 This `bc` should build unmodified on any POSIX-compliant system or on Windows
71 There is no guarantee that this `bc` will work on any version of Windows earlier
82 #### `bc`
84 To build `bc`, you can open the `vs/bc.sln` file in Visual Studio, select the
90 msbuild -property:Configuration=<config> vs/bc.sln
95 On Windows, the calculators are built as `vs/bin/<platform>/<config>/bc.exe` and
99 **Note**: On Windows, `dc.exe` is just copied from `bc.exe`; it is not linked.
121 On POSIX-compatible systems, `bc` is built as `bin/bc` and `dc` is built as
136 To only build `bc`, use the following commands:
146 ./configure.sh --disable-bc
167 By default, `bc` and `dc` will be installed in `/usr/local`. For installing in
196 For example, if the source is in `bc`, the build should happen in `build`, then
200 ../bc/configure.sh
209 When I ran benchmarks with my `bc` compiled under `clang`, it performed much
210 better than when compiled under `gcc`. I recommend compiling this `bc` with
213 I also recommend building this `bc` with C11 if you can because `bc` will detect
218 I wrote this `bc` with Separation of Concerns, which means that there are many
223 Thus, because of the way this `bc` is built, it will automatically be slower
224 than other `bc` implementations when running scripts with no math. (My `bc`'s
225 math is *much* faster, so any non-trivial script should run faster in my `bc`.)
235 Link-time optimization, in particular, speeds up the `bc` a lot. This is because
240 `bc`'s performance, at least when building with link-time optimization. See the
248 ##### Using This `bc` as an Alternative
250 If this `bc` is packaged as an alternative to an already existing `bc` package,
267 **Note**: The suggested name (and package name) when `bc` is not available is
268 `bc-gh`.
273 `bc` in the optimal configuration: `scripts/karatsuba.py`.
287 This `bc` is robust.
290 with POSIX `bc`. The math has been tested with 40+ million random problems, so
293 This `bc` can be used as a drop-in replacement for any existing `bc`. This `bc`
296 In addition, this `bc` is considered complete; i.e., there will be no more
309 for this `bc` and `dc`, including the extensions.
311 ## `bc` Libs
313 I have gathered some excellent [`bc` and `dc` libraries][18]. These libraries
316 ## Comparison to GNU `bc`
318 This `bc` compares favorably to GNU `bc`.
320 * This `bc` builds natively on Windows.
321 * It has more extensions, which make this `bc` more useful for scripting. (See
323 * This `bc` is a bit more POSIX compliant.
324 * It has a much less buggy parser. The GNU `bc` will give parse errors for what
325 is actually valid `bc` code, or should be. For example, putting an `else` on
326 a new line after a brace can cause GNU `bc` to give a parse error.
327 * This `bc` has fewer crashes.
328 * GNU `bc` calculates the wrong number of significant digits for `length(x)`.
329 * GNU `bc` will sometimes print numbers incorrectly. For example, when running
330 it on the file `tests/bc/power.txt` in this repo, GNU `bc` gets all the right
333 * This `bc` is faster. (See [Performance](#performance).)
337 Because this `bc` packs more than `1` decimal digit per hardware integer, this
338 `bc` is faster than GNU `bc` and can be *much* faster. Full benchmarks can be
341 There is one instance where this `bc` is slower: if scripts are light on math.
342 This is because this `bc`'s intepreter is slightly slower than GNU `bc`, but
347 Below is a non-comprehensive list of extensions that this `bc` and `dc` have
350 * **The `!` operator has higher precedence than the `!` operator in other `bc`
355 "invalid" digits for a particular base. GNU `bc` uses it, and the BSD `bc`
363 called that, it's possible to tell my `bc` to not treat it as a keyword, which
376 * For `bc` only, the `divmod()` built-in function for computing a quotient and
378 * For `bc` only, the `asciify()` built-in function for converting an array to a
380 * The `$` truncation operator. (It's the same in `bc` and `dc`.)
381 * The `@` "set scale" operator. (It's the same in `bc` and `dc`.)
382 * The decimal shift operators. (`<<` and `>>` in `bc`, `H` and `h` in `dc`.)
385 * The ability to put strings into variables in `bc`. (This always existed in
401 To see what algorithms this `bc` uses, see the [algorithms manual][7].
407 Additionally, this `bc` only has support for English (and US English), French,
423 Other projects based on this bc are:
425 * [busybox `bc`][8]. The busybox maintainers have made their own changes, so any
426 bugs in the busybox `bc` should be reported to them.
427 * [toybox `bc`][9]. The maintainer has also made his own changes, so bugs in the
428 toybox `bc` should be reported there.
429 * [FreeBSD `bc`][23]. While the `bc` in FreeBSD is kept up-to-date, it is better
432 * [macOS `bc`][35]. Any bugs in that `bc` should be reported to me, but do
434 * [Android Open Source `bc`][32]. Any bugs in that `bc` can be reported here.
436 This is a non-comprehensive list of Linux distros that use this `bc` as the
437 system `bc`:
439 * [Gentoo][33]; it is a first-class alternative to GNU `bc`, but not exclusive.
442 Other Linux distros package it as a second-class alternative, usually as `bc-gh`
443 or `howard-bc`.
447 This `bc` is written in pure ISO C99, using POSIX 2008 APIs with custom Windows
452 This `bc` uses the commit message guidelines laid out in [this blog post][10].
456 This `bc` uses [semantic versioning][11].
481 benchmarks A folder of benchmarks for various aspects of bc performance.
482 gen The bc math library, help texts, and code to generate C source.
491 [1]: https://www.gnu.org/software/bc/
495 [8]: https://git.busybox.net/busybox/tree/miscutils/bc.c
496 [9]: https://github.com/landley/toybox/blob/master/toys/pending/bc.c
499 [12]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html
500 [17]: https://git.gavinhoward.com/gavin/vim-bc
503 [20]: https://git.gavinhoward.com/gavin/bc
506 [23]: https://cgit.freebsd.org/src/tree/contrib/bc
512 [29]: https://github.com/gavinhoward/bc
513 [30]: ./manuals/bc/A.1.md#extended-library
515 [32]: https://android.googlesource.com/platform/external/bc/
516 [33]: https://github.com/gentoo/gentoo/blob/master/app-alternatives/bc/bc-0.ebuild#L8
517 [34]: https://www.linuxfromscratch.org/lfs/view/stable/chapter08/bc.html
518 [35]: https://github.com/apple-oss-distributions/bc/tree/main/bc