Skip to content

Commit

Permalink
Fix markdown table and further improve README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
akubera committed Mar 5, 2024
1 parent f104e98 commit 33f44aa
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions README.md
Expand Up @@ -12,12 +12,18 @@



Arbitary-precision decimal numbers implemented in pure Rust.
Arbitrary-precision decimal numbers implemented in pure Rust.

## Community

Join the conversation on Zulip: https://bigdecimal-rs.zulipchat.com

Please share important stuff like use-cases, issues, benchmarks, and
naming-convention preferences.

This project is currently being re-written, so if performance or flexibility
is lacking, check again soon and it may be fixed.

## Usage

Add bigdecimal as a dependency to your `Cargo.toml` file:
Expand Down Expand Up @@ -47,15 +53,21 @@ sqrt(2) = 1.41421356237309504880168872420969807856967187537694807317667973799073

### Compile-Time Configuration

You can set a few default parameters at compile-time via environment variables.
You can set a few default parameters at _compile-time_ via environment variables:

+-------------------------------------------------+------------+
| Environment Variable | Default |
+-------------------------------------------------+------------+
|-------------------------------------------------|------------|
| `RUST_BIGDECIMAL_DEFAULT_PRECISION` | 100 |
| `RUST_BIGDECIMAL_DEFAULT_ROUNDING_MODE` | `HalfEven` |
| `RUST_BIGDECIMAL_EXPONENTIAL_FORMAT_THRESHOLD` | 5 |
+-------------------------------------------------+------------+

These allow setting the default [Context] fields globally without incurring a runtime lookup,
or having to pass Context parameters through all calculations.
(If you want runtime control over these fields, you will have to pass Contexts to your functions.)
Examine [build.rs] for how those are converted to constants in the code (if interested).

[Context]: https://docs.rs/bigdecimal/latest/bigdecimal/struct.Context.html
[build.rs]: ./build.rs


#### Default precision
Expand All @@ -65,14 +77,14 @@ The default value of this variable is 100.

This will be used as maximum precision for operations which may produce infinite digits (inverse, sqrt, ...).

Note that other operations, such as multiplication, will preserve all digits, so multiplying two 70 digit numbers
will result in one 140 digit number.
The user will have to manually trim the number of digits after calculations to reasonable amounts using the
`x.with_prec(30)` method.

A new set of methods with explicit precision and rounding modes is being worked on, but even after those
are introduced the default precision will have to be used as the implicit value.
Note that other operations, such as multiplication, will preserve all digits;
so multiplying two 70 digit numbers will result in one 140 digit number.
The user will have to manually trim the number of digits after calculations to
reasonable amounts using the `x.with_prec(30)` method.

A new set of methods with explicit precision and rounding modes is being worked
on, but even after those are introduced the default precision will have to be
used as the implicit value.

#### Rounding mode

Expand Down Expand Up @@ -132,12 +144,6 @@ $ cargo run
> This is for flexibility and performance.

## Improvements

Work is being done on this codebase again and there are many features
and improvements on the way.


## About

This repository contains code originally meant for a bigdecimal module
Expand Down

0 comments on commit 33f44aa

Please sign in to comment.