goldkarat 0.1.0

goldkarat is a small D library for gold pricing arithmetic. Gold is quoted as a spot price per troy ounce of fine metal, but jewellery and scrap change hands by the gram at a stated karat, so a conversion sits between the quote and the transaction. This library is that conversion. Five public functions. karatPurity returns the purity factor for a karat. pricePerGram converts a spot price per troy ounce into a price per gram of fine gold. pricePerGramAtKarat applies purity to that figure. meltValue computes the scrap value of an item from its weight, karat and the spot price. convertMass moves an amount between gram, troy ounce, pennyweight and tola. The library holds no price data of its own and makes no network calls. The spot price is always an argument, so the caller decides where the quote comes from. The mass constants are declared as named enums with their derivation shown in the comments. Five unittest blocks, no dependencies, MIT licensed.

Tags d dlang library finance precious-metals units
License MITL
State initial

Recent Releases

0.1.008 Aug 2026 17:19 minor feature: Initial release. Karat purity factors, spot-per-troy-ounce to price-per-gram, price per gram at a karat, melt value from weight and karat, and mass conversion between gram, troy ounce, pennyweight and tola. Five public functions, five unittest blocks, no dependencies and no bundled price data.