Skip to main content

rest_energy

Function rest_energy 

pub fn rest_energy(mass: f64) -> Option<f64>
Expand description

Computes rest energy E0 = mc² in joules.

Returns None when mass is negative or not finite, or when the computed energy is not finite.

§Examples

use use_relativity::{SPEED_OF_LIGHT, rest_energy};

assert!((rest_energy(1.0).unwrap() - (SPEED_OF_LIGHT * SPEED_OF_LIGHT)).abs() < 1.0e-3);