#circuit #resistance #color #calculating #tolerance #bands #resistor-color

resistor

calculating the resistance of a resistor based on the color bands

2 unstable releases

0.1.0 May 16, 2023
0.0.0 May 16, 2023

#1667 in Algorithms

21 downloads per month

MPL-2.0 license

16KB
298 lines

Resistor

resistor is a library for calculating the resistance of a resistor based on the color bands.

use resistor::{ResistorBuilder, ResistorColor};
#[test]
fn test_red4() {
    let resistor = ResistorBuilder::FourBand {
        first: ResistorColor::Red,
        second: ResistorColor::Red,
        multiplier: ResistorColor::Red,
        tolerance: ResistorColor::Red,
    }
    .build()
    .unwrap();
    assert_eq!(resistor.resistance, 2200.0);
    assert_eq!(resistor.to_string(), "Resistor(2200Ω ± 2%)");
}

No runtime deps