Add a Celsius/Fahrenheit conversion module with rounding and unit tests #7
Loading…
Reference in a new issue
No description provided.
Delete branch "claude/wi-019fcd16-add-a-celsius-fahrenheit-conversion-modu"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Anima work item
019fcd16-660a-7213-916d-b21771dfe07e.What to build
The crate is a small hello-world.
Cargo.tomlisanima-canary0.1.0, edition 2021,no dependencies — keep it that way, do not add any crate.
Work from
mainas it stands. Ignore any other open branch on this repo.1.
src/temperature.rs(new file)round_to(23.456, 2)must give23.46. Implement it with10f64.powi(places as i32),not by formatting to a string.
2. Wire it into
main.rsDeclare the module. Keep the existing first line of output, then print:
Use
round_to(.., 1)on the Fahrenheit-to-Celsius line so it prints37and not36.99999999999999.3. Unit tests
In
src/temperature.rs, a#[cfg(test)] mod testscovering:c_to_f(0.0)is32.0c_to_f(100.0)is212.0f_to_c(32.0)is0.0round_to(f_to_c(98.6), 1)is37.0-40.0is the fixed point:c_to_f(-40.0)is-40.0round_to(f_to_c(c_to_f(21.5)), 4)is21.5Compare floats with an epsilon (
(a - b).abs() < 1e-9), not==, except where thevalue is exactly representable.
Acceptance
cargo buildsucceeds.cargo testpasses, with at least 6 tests.cargo clippy -- -D warningsis clean.cargo runprints the lines above, in that order.Notes
This is a canary for the turn-completion fix that just deployed — the repo is trivial on
purpose. If something blocks you, say plainly what stopped you rather than working around
it.
WIP: Add a Celsius/Fahrenheit conversion module with rounding and unit teststo Add a Celsius/Fahrenheit conversion module with rounding and unit tests4acf2f9100to2c7fb565f9