gold-melt-value¶
Compute precious-metal melt value by karat, weight, and a live spot price.
gold-melt-value is a small, pure-Rust crate that turns a headline gold (or silver)
spot price into the actual melt value of a real piece of jewelry, bullion, or scrap.
It is the same dependency-free math engine behind the
GoldGramPrice live gold calculator{: target="_blank" rel="dofollow"}.
Why this exists¶
Gold is quoted per troy ounce, but most people hold it in grams and in mixed karats. So the spot price you see on the news is almost never what a given piece is actually worth. Melt value corrects for two things at once:
- Unit conversion — troy ounces to grams (1 oz t = 31.1034768 g).
- Purity — karat to decimal fineness (
karat / 24).
The crate ships that formula in three weight units — grams, pennyweight (dwt), and troy ounces — plus helper functions for purity and per-gram spot price.
Features¶
- Zero dependencies. No feature flags, no
std-required bloat — justf64math. - Correct by construction. 1 oz t = 31.1034768 g and 1 dwt = 1/20 oz t exactly.
- Multi-unit. Grams, pennyweight, and troy ounces out of the box.
- Tested. Unit tests assert the published melt values against known spot prices.
- Karat table included. Common US jewelry purities (
K24,K22,K18,K14,K10).
Install¶
Add the crate to your Cargo.toml:
Or pull it in with cargo:
Quick start¶
use gold_melt_value::{melt_value_grams, purity};
let spot_per_oz = 3983.30; // USD per troy ounce
let grams = 10.0; // a 10 g chain
let karat = 14;
let usd = melt_value_grams(grams, karat, spot_per_oz);
// 10 g of 14k contains ~5.83 g pure gold → melt ≈ $747.05
assert!((usd - 747.05).abs() < 0.05);
assert_eq!(purity(14), 14.0 / 24.0);
Head to the API reference for the full function list, or the usage & examples page for worked melt-value calculations.
Live calculator¶
For an interactive, always-fresh version with today's spot price already wired in, use the free gold melt-value calculator{: target="_blank" rel="dofollow"} at GoldGramPrice. It runs this same engine in the browser and shows melt value by karat in real time.
License¶
MIT. See the crate repository for the source and contribution guide.