Crates.io | standardform |
lib.rs | standardform |
version | 0.2.1 |
source | src |
created_at | 2023-08-23 15:28:31.338846 |
updated_at | 2024-09-28 13:28:56.663404 |
description | Effortlessly operate on numbers like 2e19 or 2*10^4 and more with this Rust implementation of standard form. Simplify, convert, and manipulate large numerical expressions with ease. |
homepage | https://github.com/Deaths-Door/standardform-rs |
repository | https://github.com/Deaths-Door/standardform-rs |
max_upload_size | |
id | 952145 |
size | 85,806 |
Effortlessly operate on numbers like 2e19 or 2*10^4 and more with this Rust implementation of standard form. Simplify, convert, and manipulate large numerical expressions with ease.
StandardForm
struct.num_traits
crate as well.no-std
available as well.Add this library to your Cargo.toml
:
[dependencies]
standardform = "0.2.1" # Version
To enable intergation it with nom
, enable nom
feature:
[dependencies]
standardform = { version = "0.2.1" , features = ["nom"] }
Then
use standardform::StandardForm;
// Create a new StandardForm instance
let number = StandardForm::new(2.0, 19);
// Perform arithmetic operations
let result = number * StandardForm::new(1.5, -3);
// Compare numbers
if result > StandardForm::new(1.0, 10) {
println!("Result is greater than 1*10^108.");
}
Please note that the examples provided here are simplified and serve as a starting point. For comprehensive documentation of the crate, please visit the crate documentation for a better understanding of the crate's functionalities and APIs. Additionally, you can explore a website showcasing a subset of its features.
For seamless integration between Rust and Python use the following command to install the library with python bindings
pip install standardform
Use the following commands
python -m venv .venv
source .venv/bin/activate
pip install maturin
pip freeze
maturin develop --features python
For seamless integration between Rust and JavaScript, this library supports WebAssembly (Wasm). Follow these steps to update bindings when the Rust code changes:
Ensure you have wasm-pack
installed:
cargo install wasm-pack
Build the Wasm package:
wasm-pack build --target web --out-dir ./website
If you make changes to your Rust code, rebuild the Wasm package to update the bindings
This ensures that your JavaScript bindings stay synchronized with any changes made to your Rust code. Remember to update the bindings whenever you modify your Rust implementation to maintain a consistent integration between the two languages.
If you prefer not to build the JavaScript bindings yourself, you can download a pre-built version of the pkg
directory from the releases page. Follow these instructions to use the pre-built 'js' bindings:
Download the pre-built pkg
directory from the releases page.
Extract the contents of the downloaded archive.
Ensure your HTML file references the pre-built JavaScript file. Add the following script tag to your HTML file:
<script type="module">
import init , { StandardForm } from '/path-to-pkg/standardform.js';
await init()
</script>
Replace '/path-to-pkg/standardform.js'
with the correct path to the downloaded 'standardform.js' file.
Your library is now ready to be used in your JavaScript code.
In case you are using webpack
, follow this guide
Here are the guides to use this code with different methods of deployment and integration
Note: While using pre-built bindings is convenient, it's recommended to build the bindings yourself if you plan on making changes to the Rust code, as explained below
Contributions are welcome! If you find a bug or have an enhancement in mind, feel free to open an issue or submit a pull request.