natural_constants

Crates.ionatural_constants
lib.rsnatural_constants
version0.2.0
sourcesrc
created_at2017-02-20 13:52:08.449023
updated_at2022-10-11 12:33:58.960733
descriptionPre-defined constants from all disciplines (math, physics, ...)
homepage
repositoryhttps://github.com/willi-kappler/natural_constants
max_upload_size
id8604
size86,947
Willi Kappler (willi-kappler)

documentation

https://docs.rs/natural-constants

README

natural_constants

Build Status MIT licensed

Pre-defined constants from all disciplines (math, physics, ...) as a Rust library.

Add this to your Cargo.toml file:

natural_constants = "0.2.0"

Currently the following modules exist:

  • math
  • physics
  • chemistry
  • biology
  • engineering
  • conversion

It's far from complete. So if your favorite constant is missing, just let me know.

What should go in ? Everything that you think is useful. Some constants may fit into multiple modules - we then have to decide which one.

  • Why are you using long names for the constants ? Why not a simple character like 'c' ?

Well simple characters are often used ("overloaded") by various constants, so to avoid ambiguity the full name is used.

  • But isn't that too complicated to type ? Now my code looks too ugly!

Well no one stops you from doing s.th. like this:

use natural_constants::physics::*;

fn main() {
    let c = speed_of_light_vac;
    let m0 = 100.0;

    // Use c in your code:
    let E = m0 * c * c;
}
  • What about pre-calculated stuff ?

Yes, why not ? If it's useful to you, it may also be useful to others.

This is an ongoing effort to make Rust more suitable for scientific / numeric computing, you can join the discussion here.

Other useful numeric / scientific crates:

More here:

Commit count: 71

cargo fmt