Gavin Howard | 5be2072 | 2018-08-31 00:30:59 -0600 | [diff] [blame] | 1 | # `bc` |
Gavin Howard | 35221f0 | 2018-01-24 21:16:43 -0700 | [diff] [blame] | 2 | |
Gavin Howard | ae12d10 | 2020-04-09 10:44:46 -0600 | [diff] [blame] | 3 | ***WARNING: This project has moved to [https://git.yzena.com/][20] for [these |
Gavin Howard | f73c233 | 2020-04-11 11:45:18 -0600 | [diff] [blame] | 4 | reasons][21], though GitHub will remain a mirror.*** |
Gavin Howard | bc4b57b | 2020-04-08 22:11:24 -0600 | [diff] [blame] | 5 | |
Gavin Howard | 86fc8ac | 2019-02-18 10:38:13 -0700 | [diff] [blame] | 6 | This is an implementation of the [POSIX `bc` calculator][12] that implements |
| 7 | [GNU `bc`][1] extensions, as well as the period (`.`) extension for the BSD |
| 8 | flavor of `bc`. |
Gavin Howard | 35221f0 | 2018-01-24 21:16:43 -0700 | [diff] [blame] | 9 | |
Gavin Howard | 92b3b7f | 2020-06-28 16:44:34 -0600 | [diff] [blame] | 10 | For more information, see this `bc`'s full manual. |
Gavin Howard | 2c63e81 | 2018-12-31 09:09:03 -0700 | [diff] [blame] | 11 | |
Gavin Howard | 0a4d75b | 2018-10-22 17:52:03 -0600 | [diff] [blame] | 12 | This `bc` also includes an implementation of `dc` in the same binary, accessible |
Gavin Howard | 5be3461 | 2019-05-25 10:00:32 -0600 | [diff] [blame] | 13 | via a symbolic link, which implements all FreeBSD and GNU extensions. (If a |
| 14 | standalone `dc` binary is desired, `bc` can be copied and renamed to `dc`.) The |
| 15 | `!` command is omitted; I believe this poses security concerns and that such |
Gavin Howard | ff8ad3f | 2018-10-25 18:36:06 -0600 | [diff] [blame] | 16 | functionality is unnecessary. |
Gavin Howard | 17b8225 | 2018-10-12 14:20:30 -0600 | [diff] [blame] | 17 | |
Gavin Howard | 92b3b7f | 2020-06-28 16:44:34 -0600 | [diff] [blame] | 18 | For more information, see the `dc`'s full manual. |
Gavin Howard | 2c63e81 | 2018-12-31 09:09:03 -0700 | [diff] [blame] | 19 | |
Gavin Howard | 940f932 | 2021-04-17 07:56:38 -0600 | [diff] [blame] | 20 | This `bc` also provides `bc`'s math as a library with C bindings, called `bcl`. |
| 21 | |
| 22 | For more information, see the full manual for `bcl`. |
| 23 | |
Gavin Howard | b23cb38 | 2021-07-11 15:57:33 -0600 | [diff] [blame] | 24 | ## License |
| 25 | |
Gavin Howard | 0a4d75b | 2018-10-22 17:52:03 -0600 | [diff] [blame] | 26 | This `bc` is Free and Open Source Software (FOSS). It is offered under the BSD |
Gavin Howard | 880977e | 2019-01-24 10:06:28 -0700 | [diff] [blame] | 27 | 2-clause License. Full license text may be found in the [`LICENSE.md`][4] file. |
Gavin Howard | 5715b04 | 2018-02-12 16:11:42 -0700 | [diff] [blame] | 28 | |
Gavin Howard | 32a5913 | 2019-02-02 09:43:15 -0700 | [diff] [blame] | 29 | ## Prerequisites |
| 30 | |
Gavin Howard | f9f45cd | 2021-04-04 22:59:54 -0600 | [diff] [blame] | 31 | This `bc` only requires either: |
| 32 | |
| 33 | 1. Windows 10 or later, or |
| 34 | 2. A C99-compatible compiler and a (mostly) POSIX 2008-compatible system with |
| 35 | the XSI (X/Open System Interfaces) option group. |
Gavin Howard | 32a5913 | 2019-02-02 09:43:15 -0700 | [diff] [blame] | 36 | |
Gavin Howard | beaf8fa | 2020-06-04 08:19:44 -0600 | [diff] [blame] | 37 | Since POSIX 2008 with XSI requires the existence of a C99 compiler as `c99`, any |
Gavin Howard | bd90f2b | 2020-05-13 12:11:38 -0600 | [diff] [blame] | 38 | POSIX and XSI-compatible system will have everything needed. |
Gavin Howard | 990fe17 | 2019-02-02 11:32:40 -0700 | [diff] [blame] | 39 | |
Gavin Howard | f9f45cd | 2021-04-04 22:59:54 -0600 | [diff] [blame] | 40 | POSIX-compatible systems that are known to work: |
Gavin Howard | 990fe17 | 2019-02-02 11:32:40 -0700 | [diff] [blame] | 41 | |
| 42 | * Linux |
| 43 | * FreeBSD |
Gavin Howard | 78d03c9 | 2019-04-06 23:36:47 -0600 | [diff] [blame] | 44 | * OpenBSD |
Gavin Howard | 7d25ecb | 2019-05-26 09:16:55 -0600 | [diff] [blame] | 45 | * NetBSD |
Gavin Howard | 22ba096 | 2019-02-18 21:04:03 -0700 | [diff] [blame] | 46 | * Mac OSX |
Gavin Howard | a595c0e | 2020-06-26 09:11:03 -0600 | [diff] [blame] | 47 | * Solaris* (as long as the Solaris version supports POSIX 2008) |
Gavin Howard | 29f1f48 | 2020-04-28 16:58:38 -0600 | [diff] [blame] | 48 | * AIX |
Gavin Howard | 9e0dccd | 2020-12-20 18:14:05 -0700 | [diff] [blame] | 49 | * HP-UX* (except for history) |
Gavin Howard | 990fe17 | 2019-02-02 11:32:40 -0700 | [diff] [blame] | 50 | |
Gavin Howard | f9f45cd | 2021-04-04 22:59:54 -0600 | [diff] [blame] | 51 | In addition, there is compatibility code to make this `bc` work on Windows. |
| 52 | |
Gavin Howard | 4e21882 | 2019-02-20 11:14:31 -0700 | [diff] [blame] | 53 | Please submit bug reports if this `bc` does not build out of the box on any |
Gavin Howard | f9f45cd | 2021-04-04 22:59:54 -0600 | [diff] [blame] | 54 | system. |
Gavin Howard | 32a5913 | 2019-02-02 09:43:15 -0700 | [diff] [blame] | 55 | |
Gavin Howard | f41ab45 | 2018-04-17 02:06:04 -0600 | [diff] [blame] | 56 | ## Build |
Gavin Howard | df6890a | 2018-03-24 11:02:31 -0600 | [diff] [blame] | 57 | |
Gavin Howard | c973756 | 2021-05-13 13:05:23 -0600 | [diff] [blame] | 58 | This `bc` should build unmodified on any POSIX-compliant system or on Windows |
| 59 | starting with Windows 10 (though earlier versions may work). |
| 60 | |
| 61 | For more complex build requirements than the ones below, see the |
| 62 | [build manual][5]. |
| 63 | |
Gavin Howard | f9f45cd | 2021-04-04 22:59:54 -0600 | [diff] [blame] | 64 | ### Windows |
| 65 | |
| 66 | There is no guarantee that this `bc` will work on any version of Windows earlier |
| 67 | than Windows 10 (I cannot test on earlier versions), but it is guaranteed to |
| 68 | work on Windows 10 at least. |
| 69 | |
| 70 | Also, if building with MSBuild, the MSBuild bundled with Visual Studio is |
| 71 | required. |
| 72 | |
| 73 | **Note**: Unlike the POSIX-compatible platforms, only one build configuration is |
| 74 | supported on Windows: extra math and prompt enabled, history and NLS (locale |
| 75 | support) disabled, with both calculators built. |
| 76 | |
| 77 | #### `bc` |
| 78 | |
| 79 | To build `bc`, you can open the `bc.sln` file in Visual Studio, select the |
| 80 | configuration, and build. |
| 81 | |
| 82 | You can also build using MSBuild with the following from the root directory: |
| 83 | |
| 84 | ``` |
| 85 | msbuild -property:Configuration=<config> bc.sln |
| 86 | ``` |
| 87 | |
| 88 | where `<config>` is either one of `Debug` or `Release`. |
| 89 | |
| 90 | #### `bcl` (Library) |
| 91 | |
| 92 | To build the library, you can open the `bcl.sln` file in Visual Studio, select |
| 93 | the configuration, and build. |
| 94 | |
| 95 | You can also build using MSBuild with the following from the root directory: |
| 96 | |
| 97 | ``` |
| 98 | msbuild -property:Configuration=<config> bcl.sln |
| 99 | ``` |
| 100 | |
| 101 | where `<config>` is either one of `Debug` or `Release`. |
| 102 | |
| 103 | ### POSIX-Compatible Systems |
| 104 | |
Gavin Howard | f9f45cd | 2021-04-04 22:59:54 -0600 | [diff] [blame] | 105 | On POSIX-compatible systems, `bc` is built as `bin/bc` and `dc` is built as |
| 106 | `bin/dc` by default. On Windows, they are built as `Release/bc/bc.exe` and |
| 107 | `Release/bc/dc.exe`. |
| 108 | |
| 109 | **Note**: On Windows, `dc.exe` is just copied from `bc.exe`; it is not linked. |
| 110 | Patches are welcome for a way to do that. |
| 111 | |
| 112 | #### Default |
Gavin Howard | efc4524 | 2019-01-04 15:30:54 -0700 | [diff] [blame] | 113 | |
Gavin Howard | 573c939 | 2019-01-04 15:27:52 -0700 | [diff] [blame] | 114 | For the default build with optimization, use the following commands in the root |
| 115 | directory: |
Gavin Howard | 6235f0f | 2018-10-25 15:50:00 -0600 | [diff] [blame] | 116 | |
| 117 | ``` |
Gavin Howard | 79f605c | 2019-01-08 13:08:21 -0700 | [diff] [blame] | 118 | ./configure.sh -O3 |
Gavin Howard | 0f44900 | 2018-12-12 03:35:27 -0700 | [diff] [blame] | 119 | make |
Gavin Howard | efc4524 | 2019-01-04 15:30:54 -0700 | [diff] [blame] | 120 | ``` |
| 121 | |
Gavin Howard | f9f45cd | 2021-04-04 22:59:54 -0600 | [diff] [blame] | 122 | #### One Calculator |
Gavin Howard | 78d03c9 | 2019-04-06 23:36:47 -0600 | [diff] [blame] | 123 | |
| 124 | To only build `bc`, use the following commands: |
| 125 | |
| 126 | ``` |
| 127 | ./configure.sh --disable-dc |
| 128 | make |
| 129 | ``` |
| 130 | |
| 131 | To only build `dc`, use the following commands: |
| 132 | |
| 133 | ``` |
| 134 | ./configure.sh --disable-bc |
| 135 | make |
| 136 | ``` |
| 137 | |
Gavin Howard | f9f45cd | 2021-04-04 22:59:54 -0600 | [diff] [blame] | 138 | #### Debug |
Gavin Howard | efc4524 | 2019-01-04 15:30:54 -0700 | [diff] [blame] | 139 | |
| 140 | For debug builds, use the following commands in the root directory: |
| 141 | |
| 142 | ``` |
Gavin Howard | 79f605c | 2019-01-08 13:08:21 -0700 | [diff] [blame] | 143 | ./configure.sh -g |
Gavin Howard | efc4524 | 2019-01-04 15:30:54 -0700 | [diff] [blame] | 144 | make |
Gavin Howard | 6235f0f | 2018-10-25 15:50:00 -0600 | [diff] [blame] | 145 | ``` |
| 146 | |
Gavin Howard | f9f45cd | 2021-04-04 22:59:54 -0600 | [diff] [blame] | 147 | #### Install |
Gavin Howard | 8a6fda9 | 2019-01-04 15:33:57 -0700 | [diff] [blame] | 148 | |
Gavin Howard | 4396732 | 2019-01-23 20:52:41 -0700 | [diff] [blame] | 149 | To install, use the following command: |
| 150 | |
| 151 | ``` |
| 152 | make install |
| 153 | ``` |
| 154 | |
Gavin Howard | 880977e | 2019-01-24 10:06:28 -0700 | [diff] [blame] | 155 | By default, `bc` and `dc` will be installed in `/usr/local`. For installing in |
Gavin Howard | 5be3461 | 2019-05-25 10:00:32 -0600 | [diff] [blame] | 156 | other locations, use the `PREFIX` environment variable when running |
| 157 | `configure.sh` or pass the `--prefix=<prefix>` option to `configure.sh`. See the |
| 158 | [build manual][5], or run `./configure.sh --help`, for more details. |
| 159 | |
Gavin Howard | f9f45cd | 2021-04-04 22:59:54 -0600 | [diff] [blame] | 160 | #### Library |
Gavin Howard | 7475bee | 2020-11-25 22:25:37 -0700 | [diff] [blame] | 161 | |
| 162 | This `bc` does provide a way to build a math library with C bindings. This is |
| 163 | done by the `-a` or `--library` options to `configure.sh`: |
| 164 | |
| 165 | ``` |
| 166 | ./configure.sh -a |
| 167 | ``` |
| 168 | |
| 169 | When building the library, the executables are not built. For more information, |
| 170 | see the [build manual][5]. |
| 171 | |
Gavin Howard | 8b5e7ab | 2020-11-25 22:29:34 -0700 | [diff] [blame] | 172 | The library API can be found in [`manuals/bcl.3.md`][26] or `man bcl` once the |
| 173 | library is installed. |
| 174 | |
Gavin Howard | f9f45cd | 2021-04-04 22:59:54 -0600 | [diff] [blame] | 175 | The library is built as `bin/libbcl.a` on POSIX-compatible systems or as |
| 176 | `Release/bcl/bcl.lib` on Windows. |
Gavin Howard | 4fcecf0 | 2020-11-26 08:58:39 -0700 | [diff] [blame] | 177 | |
Gavin Howard | f9f45cd | 2021-04-04 22:59:54 -0600 | [diff] [blame] | 178 | #### Package and Distro Maintainers |
Gavin Howard | 5be3461 | 2019-05-25 10:00:32 -0600 | [diff] [blame] | 179 | |
Gavin Howard | f9f45cd | 2021-04-04 22:59:54 -0600 | [diff] [blame] | 180 | ##### Recommended Compiler |
Gavin Howard | 936bc9a | 2019-07-05 08:09:31 -0600 | [diff] [blame] | 181 | |
| 182 | When I ran benchmarks with my `bc` compiled under `clang`, it performed much |
| 183 | better than when compiled under `gcc`. I recommend compiling this `bc` with |
| 184 | `clang`. |
| 185 | |
Gavin Howard | fa1a93d | 2020-06-06 12:17:06 -0600 | [diff] [blame] | 186 | I also recommend building this `bc` with C11 if you can because `bc` will detect |
| 187 | a C11 compiler and add `_Noreturn` to any relevant function(s). |
| 188 | |
Gavin Howard | f9f45cd | 2021-04-04 22:59:54 -0600 | [diff] [blame] | 189 | ##### Recommended Optimizations |
Gavin Howard | 31f180b | 2019-06-14 08:08:38 -0600 | [diff] [blame] | 190 | |
| 191 | I wrote this `bc` with Separation of Concerns, which means that there are many |
| 192 | small functions that could be inlined. However, they are often called across |
| 193 | file boundaries, and the default optimizer can only look at the current file, |
| 194 | which means that they are not inlined. |
| 195 | |
| 196 | Thus, because of the way this `bc` is built, it will automatically be slower |
| 197 | than other `bc` implementations when running scripts with no math. (My `bc`'s |
| 198 | math is *much* faster, so any non-trivial script should run faster in my `bc`.) |
| 199 | |
| 200 | Some, or all, of the difference can be made up with the right optimizations. The |
| 201 | optimizations I recommend are: |
| 202 | |
| 203 | 1. `-O3` |
| 204 | 2. `-flto` (link-time optimization) |
Gavin Howard | 31f180b | 2019-06-14 08:08:38 -0600 | [diff] [blame] | 205 | |
| 206 | in that order. |
| 207 | |
| 208 | Link-time optimization, in particular, speeds up the `bc` a lot. This is because |
| 209 | when link-time optimization is turned on, the optimizer can look across files |
| 210 | and inline *much* more heavily. |
| 211 | |
Gavin Howard | e919f3f | 2020-06-16 17:23:04 -0600 | [diff] [blame] | 212 | However, I recommend ***NOT*** using `-march=native`. Doing so will reduce this |
| 213 | `bc`'s performance, at least when building with link-time optimization. See the |
| 214 | [benchmarks][19] for more details. |
Gavin Howard | 31f180b | 2019-06-14 08:08:38 -0600 | [diff] [blame] | 215 | |
Gavin Howard | f9f45cd | 2021-04-04 22:59:54 -0600 | [diff] [blame] | 216 | ##### Stripping Binaries |
Gavin Howard | 96ac427 | 2019-11-27 22:16:26 -0700 | [diff] [blame] | 217 | |
| 218 | By default, non-debug binaries are stripped, but stripping can be disabled with |
| 219 | the `-T` option to `configure.sh`. |
| 220 | |
Gavin Howard | f9f45cd | 2021-04-04 22:59:54 -0600 | [diff] [blame] | 221 | ##### Using This `bc` as an Alternative |
Gavin Howard | eba65c7 | 2019-05-25 15:14:33 -0600 | [diff] [blame] | 222 | |
| 223 | If this `bc` is packaged as an alternative to an already existing `bc` package, |
| 224 | it is possible to rename it in the build to prevent name collision. To prepend |
| 225 | to the name, just run the following: |
| 226 | |
| 227 | ``` |
| 228 | EXECPREFIX=<some_prefix> ./configure.sh |
| 229 | ``` |
| 230 | |
| 231 | To append to the name, just run the following: |
| 232 | |
| 233 | ``` |
| 234 | EXECSUFFIX=<some_suffix> ./configure.sh |
| 235 | ``` |
| 236 | |
| 237 | If a package maintainer wishes to add both a prefix and a suffix, that is |
| 238 | allowed. |
| 239 | |
Gavin Howard | 26ce518 | 2020-04-29 16:25:57 -0600 | [diff] [blame] | 240 | **Note**: The suggested name (and package name) when `bc` is not available is |
| 241 | `bc-gh`. |
Gavin Howard | eba65c7 | 2019-05-25 15:14:33 -0600 | [diff] [blame] | 242 | |
Gavin Howard | f9f45cd | 2021-04-04 22:59:54 -0600 | [diff] [blame] | 243 | ##### Karatsuba Number |
Gavin Howard | eba65c7 | 2019-05-25 15:14:33 -0600 | [diff] [blame] | 244 | |
Gavin Howard | 5be3461 | 2019-05-25 10:00:32 -0600 | [diff] [blame] | 245 | Package and distro maintainers have one tool at their disposal to build this |
Gavin Howard | 781e6eb | 2021-06-15 11:01:29 -0600 | [diff] [blame] | 246 | `bc` in the optimal configuration: `scripts/karatsuba.py`. |
Gavin Howard | 5be3461 | 2019-05-25 10:00:32 -0600 | [diff] [blame] | 247 | |
| 248 | This script is not a compile-time or runtime prerequisite; it is for package and |
| 249 | distro maintainers to run once when a package is being created. It finds the |
| 250 | optimal Karatsuba number (see the [algorithms manual][7] for more information) |
| 251 | for the machine that it is running on. |
| 252 | |
Gavin Howard | 96b66a4 | 2020-05-14 12:37:39 -0600 | [diff] [blame] | 253 | The easiest way to run this script is with `make karatsuba`. |
| 254 | |
Gavin Howard | 5be3461 | 2019-05-25 10:00:32 -0600 | [diff] [blame] | 255 | If desired, maintainers can also skip running this script because there is a |
| 256 | sane default for the Karatsuba number. |
Gavin Howard | 8a6fda9 | 2019-01-04 15:33:57 -0700 | [diff] [blame] | 257 | |
Gavin Howard | 255526b | 2018-02-09 12:10:14 -0700 | [diff] [blame] | 258 | ## Status |
| 259 | |
Gavin Howard | 0a4d75b | 2018-10-22 17:52:03 -0600 | [diff] [blame] | 260 | This `bc` is robust. |
| 261 | |
Gavin Howard | 27c5e7f | 2018-10-25 10:57:36 -0600 | [diff] [blame] | 262 | It is well-tested, fuzzed, and fully standards-compliant (though not certified) |
Gavin Howard | 31772bd | 2019-01-24 10:14:01 -0700 | [diff] [blame] | 263 | with POSIX `bc`. The math has been tested with 40+ million random problems, so |
Gavin Howard | f406f80 | 2018-10-26 10:26:14 -0600 | [diff] [blame] | 264 | it is as correct as I can make it. |
| 265 | |
Gavin Howard | 89c13d0 | 2019-01-04 12:36:45 -0700 | [diff] [blame] | 266 | This `bc` can be used as a drop-in replacement for any existing `bc`. This `bc` |
| 267 | is also compatible with MinGW toolchains, though history is not supported on |
| 268 | Windows. |
Gavin Howard | 0a4d75b | 2018-10-22 17:52:03 -0600 | [diff] [blame] | 269 | |
Gavin Howard | d7fc56c | 2019-07-03 18:55:03 -0600 | [diff] [blame] | 270 | In addition, this `bc` is considered complete; i.e., there will be no more |
| 271 | releases with additional features. However, it *is* actively maintained, so if |
Gavin Howard | ea694cb | 2019-07-03 19:28:38 -0600 | [diff] [blame] | 272 | any bugs are found, they will be fixed in new releases. Also, additional |
| 273 | translations will also be added as they are provided. |
Gavin Howard | d7fc56c | 2019-07-03 18:55:03 -0600 | [diff] [blame] | 274 | |
Gavin Howard | 470bf61 | 2021-06-14 23:07:08 -0600 | [diff] [blame] | 275 | ### Development |
| 276 | |
| 277 | If I (Gavin D. Howard) get [hit by a bus][27] and future programmers need to |
| 278 | handle work themselves, the best place to start is the [Development manual][28]. |
| 279 | |
Gavin Howard | 3ccdab8 | 2021-07-02 00:35:40 -0600 | [diff] [blame] | 280 | ## Vim Syntax |
| 281 | |
Gavin Howard | b23cb38 | 2021-07-11 15:57:33 -0600 | [diff] [blame] | 282 | I have developed (using other people's code to start) [`vim` syntax files][17] |
Gavin Howard | 3ccdab8 | 2021-07-02 00:35:40 -0600 | [diff] [blame] | 283 | for this `bc` and `dc`, including the extensions. |
| 284 | |
| 285 | ## `bc` Libs |
| 286 | |
Gavin Howard | b23cb38 | 2021-07-11 15:57:33 -0600 | [diff] [blame] | 287 | I have gathered some excellent [`bc` and `dc` libraries][18]. These libraries |
Gavin Howard | 3ccdab8 | 2021-07-02 00:35:40 -0600 | [diff] [blame] | 288 | may prove useful to any serious users. |
| 289 | |
Gavin Howard | 3c6786e | 2021-06-16 16:34:48 -0600 | [diff] [blame] | 290 | ## Comparison to GNU `bc` |
Gavin Howard | 4c83f89 | 2019-05-25 09:23:20 -0600 | [diff] [blame] | 291 | |
Gavin Howard | 3c6786e | 2021-06-16 16:34:48 -0600 | [diff] [blame] | 292 | This `bc` compares favorably to GNU `bc`. |
Gavin Howard | 4c83f89 | 2019-05-25 09:23:20 -0600 | [diff] [blame] | 293 | |
Gavin Howard | f9f45cd | 2021-04-04 22:59:54 -0600 | [diff] [blame] | 294 | * This `bc` builds natively on Windows. |
Gavin Howard | 4c83f89 | 2019-05-25 09:23:20 -0600 | [diff] [blame] | 295 | * It has more extensions, which make this `bc` more useful for scripting. |
| 296 | * This `bc` is a bit more POSIX compliant. |
| 297 | * It has a much less buggy parser. The GNU `bc` will give parse errors for what |
| 298 | is actually valid `bc` code, or should be. For example, putting an `else` on |
| 299 | a new line after a brace can cause GNU `bc` to give a parse error. |
| 300 | * This `bc` has fewer crashes. |
Gavin Howard | aadd436 | 2019-06-05 22:28:31 -0600 | [diff] [blame] | 301 | * GNU `bc` calculates the wrong number of significant digits for `length(x)`. |
Gavin Howard | 4c83f89 | 2019-05-25 09:23:20 -0600 | [diff] [blame] | 302 | * GNU `bc` will sometimes print numbers incorrectly. For example, when running |
| 303 | it on the file `tests/bc/power.txt` in this repo, GNU `bc` gets all the right |
Gavin Howard | 21a2f96 | 2019-06-13 08:27:02 -0600 | [diff] [blame] | 304 | answers, but it fails to wrap the numbers at the proper place when outputting |
| 305 | to a file. |
Gavin Howard | 4c83f89 | 2019-05-25 09:23:20 -0600 | [diff] [blame] | 306 | * This `bc` is faster. (See [Performance](#performance).) |
| 307 | |
Gavin Howard | 0a4d75b | 2018-10-22 17:52:03 -0600 | [diff] [blame] | 308 | ### Performance |
| 309 | |
Gavin Howard | 4c83f89 | 2019-05-25 09:23:20 -0600 | [diff] [blame] | 310 | Because this `bc` packs more than `1` decimal digit per hardware integer, this |
| 311 | `bc` is faster than GNU `bc` and can be *much* faster. Full benchmarks can be |
| 312 | found at [manuals/benchmarks.md][19]. |
Gavin Howard | 0a4d75b | 2018-10-22 17:52:03 -0600 | [diff] [blame] | 313 | |
Gavin Howard | 8bc4885 | 2019-05-25 09:33:47 -0600 | [diff] [blame] | 314 | There is one instance where this `bc` is slower: if scripts are light on math. |
| 315 | This is because this `bc`'s intepreter is slightly slower than GNU `bc`, but |
| 316 | that is because it is more robust. See the [benchmarks][19]. |
| 317 | |
Gavin Howard | 573c939 | 2019-01-04 15:27:52 -0700 | [diff] [blame] | 318 | ## Algorithms |
Gavin Howard | 0a4d75b | 2018-10-22 17:52:03 -0600 | [diff] [blame] | 319 | |
Gavin Howard | 880977e | 2019-01-24 10:06:28 -0700 | [diff] [blame] | 320 | To see what algorithms this `bc` uses, see the [algorithms manual][7]. |
Gavin Howard | 0a4d75b | 2018-10-22 17:52:03 -0600 | [diff] [blame] | 321 | |
Gavin Howard | 7876e78 | 2019-02-20 16:45:10 -0700 | [diff] [blame] | 322 | ## Locales |
| 323 | |
Gavin Howard | f9f45cd | 2021-04-04 22:59:54 -0600 | [diff] [blame] | 324 | Currently, there is no locale support on Windows. |
| 325 | |
| 326 | Additionally, this `bc` only has support for English (and US English), French, |
Gavin Howard | a05e221 | 2020-04-29 10:48:42 -0600 | [diff] [blame] | 327 | German, Portuguese, Dutch, Polish, Russian, Japanese, and Chinese locales. |
| 328 | Patches are welcome for translations; use the existing `*.msg` files in |
| 329 | `locales/` as a starting point. |
| 330 | |
| 331 | In addition, patches for improvements are welcome; the last two messages in |
| 332 | Portuguese were made with Google Translate, and the Dutch, Polish, Russian, |
| 333 | Japanese, and Chinese locales were all generated with [DeepL][22]. |
Stefan Esser | b134646 | 2019-04-20 18:14:00 +0200 | [diff] [blame] | 334 | |
Gavin Howard | dd50a58 | 2019-05-09 15:26:18 -0600 | [diff] [blame] | 335 | The message files provided assume that locales apply to all regions where a |
| 336 | language is used, but this might not be true for, e.g., `fr_CA` and `fr_CH`. |
| 337 | Any corrections or a confirmation that the current texts are acceptable for |
Stefan Esser | b134646 | 2019-04-20 18:14:00 +0200 | [diff] [blame] | 338 | those regions would be appreciated, too. |
Gavin Howard | b223016 | 2019-03-16 21:44:19 -0600 | [diff] [blame] | 339 | |
Gavin Howard | 573c939 | 2019-01-04 15:27:52 -0700 | [diff] [blame] | 340 | ## Other Projects |
Gavin Howard | 0a4d75b | 2018-10-22 17:52:03 -0600 | [diff] [blame] | 341 | |
Gavin Howard | 573c939 | 2019-01-04 15:27:52 -0700 | [diff] [blame] | 342 | Other projects based on this bc are: |
Gavin Howard | 0a4d75b | 2018-10-22 17:52:03 -0600 | [diff] [blame] | 343 | |
Gavin Howard | 880977e | 2019-01-24 10:06:28 -0700 | [diff] [blame] | 344 | * [busybox `bc`][8]. The busybox maintainers have made their own changes, so any |
| 345 | bugs in the busybox `bc` should be reported to them. |
Gavin Howard | 0a4d75b | 2018-10-22 17:52:03 -0600 | [diff] [blame] | 346 | |
Gavin Howard | 880977e | 2019-01-24 10:06:28 -0700 | [diff] [blame] | 347 | * [toybox `bc`][9]. The maintainer has also made his own changes, so bugs in the |
| 348 | toybox `bc` should be reported there. |
Gavin Howard | 255526b | 2018-02-09 12:10:14 -0700 | [diff] [blame] | 349 | |
Gavin Howard | 79a1c82 | 2020-07-06 17:22:05 -0600 | [diff] [blame] | 350 | * [FreeBSD `bc`][23]. While the `bc` in FreeBSD is kept up-to-date, it is better |
Gavin Howard | 2c6ab7a | 2020-07-27 08:24:03 -0600 | [diff] [blame] | 351 | to [report bugs there][24], as well as [submit patches][25], and the |
| 352 | maintainers of the package will contact me if necessary. |
Gavin Howard | 79a1c82 | 2020-07-06 17:22:05 -0600 | [diff] [blame] | 353 | |
Gavin Howard | 5715b04 | 2018-02-12 16:11:42 -0700 | [diff] [blame] | 354 | ## Language |
| 355 | |
Gavin Howard | f9f45cd | 2021-04-04 22:59:54 -0600 | [diff] [blame] | 356 | This `bc` is written in pure ISO C99, using POSIX 2008 APIs with custom Windows |
| 357 | compatibility code. |
Gavin Howard | 5715b04 | 2018-02-12 16:11:42 -0700 | [diff] [blame] | 358 | |
Gavin Howard | 5715b04 | 2018-02-12 16:11:42 -0700 | [diff] [blame] | 359 | ## Commit Messages |
| 360 | |
Gavin Howard | 880977e | 2019-01-24 10:06:28 -0700 | [diff] [blame] | 361 | This `bc` uses the commit message guidelines laid out in [this blog post][10]. |
Gavin Howard | 5715b04 | 2018-02-12 16:11:42 -0700 | [diff] [blame] | 362 | |
| 363 | ## Semantic Versioning |
| 364 | |
Gavin Howard | 880977e | 2019-01-24 10:06:28 -0700 | [diff] [blame] | 365 | This `bc` uses [semantic versioning][11]. |
Gavin Howard | 5715b04 | 2018-02-12 16:11:42 -0700 | [diff] [blame] | 366 | |
Gavin Howard | 5715b04 | 2018-02-12 16:11:42 -0700 | [diff] [blame] | 367 | ## Contents |
| 368 | |
Gavin Howard | 9a3ff00 | 2019-01-23 20:53:41 -0700 | [diff] [blame] | 369 | Items labeled with `(maintainer use only)` are not included in release source |
Gavin Howard | d6269bf | 2019-01-07 19:15:36 -0700 | [diff] [blame] | 370 | tarballs. |
| 371 | |
Gavin Howard | 5715b04 | 2018-02-12 16:11:42 -0700 | [diff] [blame] | 372 | Files: |
| 373 | |
Gavin Howard | f74beef | 2019-04-01 14:11:44 -0600 | [diff] [blame] | 374 | .gitignore The git ignore file (maintainer use only). |
Gavin Howard | f9f45cd | 2021-04-04 22:59:54 -0600 | [diff] [blame] | 375 | .gitattributes The git attributes file (maintainer use only). |
| 376 | bc.sln The Visual Studio solution file for bc. |
| 377 | bc.vcxproj The Visual Studio project file for bc. |
| 378 | bc.vcxproj.filters The Visual Studio filters file for bc. |
| 379 | bcl.sln The Visual Studio solution file for bcl. |
| 380 | bcl.vcxproj The Visual Studio project file for bcl. |
| 381 | bcl.vcxproj.filters The Visual Studio filters file for bcl. |
Gavin Howard | 7a45a98 | 2020-03-20 10:07:04 -0600 | [diff] [blame] | 382 | configure A symlink to configure.sh to make packaging easier. |
Gavin Howard | f74beef | 2019-04-01 14:11:44 -0600 | [diff] [blame] | 383 | configure.sh The configure script. |
Gavin Howard | f74beef | 2019-04-01 14:11:44 -0600 | [diff] [blame] | 384 | LICENSE.md A Markdown form of the BSD 2-clause License. |
Gavin Howard | f74beef | 2019-04-01 14:11:44 -0600 | [diff] [blame] | 385 | Makefile.in The Makefile template. |
| 386 | NOTICE.md List of contributors and copyright owners. |
| 387 | RELEASE.md A checklist for making a release (maintainer use only). |
Gavin Howard | 5715b04 | 2018-02-12 16:11:42 -0700 | [diff] [blame] | 388 | |
| 389 | Folders: |
| 390 | |
Gavin Howard | 5211162 | 2019-01-24 10:23:31 -0700 | [diff] [blame] | 391 | gen The bc math library, help texts, and code to generate C source. |
Gavin Howard | 3157edf | 2018-10-15 08:28:10 -0600 | [diff] [blame] | 392 | include All header files. |
Gavin Howard | 7876e78 | 2019-02-20 16:45:10 -0700 | [diff] [blame] | 393 | locales Locale files, in .msg format. Patches welcome for translations. |
Gavin Howard | 0386d24 | 2019-01-04 15:35:17 -0700 | [diff] [blame] | 394 | manuals Manuals for both programs. |
Gavin Howard | 54eafec | 2018-10-12 14:23:56 -0600 | [diff] [blame] | 395 | src All source code. |
Gavin Howard | 781e6eb | 2021-06-15 11:01:29 -0600 | [diff] [blame] | 396 | scripts A bunch of shell scripts to help with development and building. |
Gavin Howard | 54eafec | 2018-10-12 14:23:56 -0600 | [diff] [blame] | 397 | tests All tests. |
Gavin Howard | 0a4d75b | 2018-10-22 17:52:03 -0600 | [diff] [blame] | 398 | |
Gavin Howard | 880977e | 2019-01-24 10:06:28 -0700 | [diff] [blame] | 399 | [1]: https://www.gnu.org/software/bc/ |
Gavin Howard | 880977e | 2019-01-24 10:06:28 -0700 | [diff] [blame] | 400 | [4]: ./LICENSE.md |
| 401 | [5]: ./manuals/build.md |
Gavin Howard | 880977e | 2019-01-24 10:06:28 -0700 | [diff] [blame] | 402 | [7]: ./manuals/algorithms.md |
| 403 | [8]: https://git.busybox.net/busybox/tree/miscutils/bc.c |
| 404 | [9]: https://github.com/landley/toybox/blob/master/toys/pending/bc.c |
| 405 | [10]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html |
| 406 | [11]: http://semver.org/ |
Gavin Howard | 86fc8ac | 2019-02-18 10:38:13 -0700 | [diff] [blame] | 407 | [12]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html |
Gavin Howard | b23cb38 | 2021-07-11 15:57:33 -0600 | [diff] [blame] | 408 | [17]: https://git.yzena.com/gavin/vim-bc |
| 409 | [18]: https://git.yzena.com/gavin/bc_libs |
Gavin Howard | 4c83f89 | 2019-05-25 09:23:20 -0600 | [diff] [blame] | 410 | [19]: ./manuals/benchmarks.md |
Gavin Howard | 030a754 | 2020-04-09 10:41:07 -0600 | [diff] [blame] | 411 | [20]: https://git.yzena.com/gavin/bc |
Gavin Howard | 409599c | 2020-04-08 22:22:08 -0600 | [diff] [blame] | 412 | [21]: https://gavinhoward.com/2020/04/i-am-moving-away-from-github/ |
Gavin Howard | a05e221 | 2020-04-29 10:48:42 -0600 | [diff] [blame] | 413 | [22]: https://www.deepl.com/translator |
Gavin Howard | 4e6e799 | 2021-02-07 23:32:13 -0700 | [diff] [blame] | 414 | [23]: https://cgit.freebsd.org/src/tree/contrib/bc |
Gavin Howard | 3c2febe | 2020-07-28 19:43:28 -0600 | [diff] [blame] | 415 | [24]: https://bugs.freebsd.org/ |
Gavin Howard | 2c6ab7a | 2020-07-27 08:24:03 -0600 | [diff] [blame] | 416 | [25]: https://reviews.freebsd.org/ |
Gavin Howard | 8b5e7ab | 2020-11-25 22:29:34 -0700 | [diff] [blame] | 417 | [26]: ./manuals/bcl.3.md |
Gavin Howard | 470bf61 | 2021-06-14 23:07:08 -0600 | [diff] [blame] | 418 | [27]: https://en.wikipedia.org/wiki/Bus_factor |
| 419 | [28]: ./manuals/development.md |