GoldKaratValue 0.1.0

dotnet add package GoldKaratValue --version 0.1.0
                    
NuGet\Install-Package GoldKaratValue -Version 0.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="GoldKaratValue" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GoldKaratValue" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="GoldKaratValue" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add GoldKaratValue --version 0.1.0
                    
#r "nuget: GoldKaratValue, 0.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package GoldKaratValue@0.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=GoldKaratValue&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=GoldKaratValue&version=0.1.0
                    
Install as a Cake Tool

GoldKaratValue

Estimate gold melt value from karat, weight, and a 24K price per gram.

Jewelry and scrap workflows usually start from the same three inputs: how heavy the piece is, what karat stamp it carries, and what fine gold is trading at today. This library keeps that math in one place so a .NET app or script can reuse the same rounding rules.

It does not call a price API. You pass in the 24K price you already have (spot feed, cached quote, or a number typed by the user).

Install

dotnet add package GoldKaratValue

Usage

using GoldKaratValue;

var melt = Calculator.MeltValue(10, WeightUnit.Gram, 14, 65);
Console.WriteLine($"14K melt: ${melt.Total:0.00} (${melt.PerGram:0.00}/g)");

var scrap = Calculator.ScrapValue(10, WeightUnit.Gram, 14, 65, 0.85);
Console.WriteLine($"85% scrap offer: ${scrap.Scrap:0.00}");

WeightUnit covers grams, pennyweight, troy ounces, troy pounds, and kilograms. Karat must be between 0 and 24 (including fractional stamps such as 21.6).

Formula

  1. Convert the entered weight to grams.
  2. Purity ratio = karat ÷ 24 (14K ≈ 0.5833).
  3. Price per gram at that karat = 24K price per gram × ratio, rounded to cents.
  4. Melt value = grams × that per-gram price, rounded to cents.
  5. Scrap estimate = melt value × a payout ratio between 0 and 1 (for example 0.50 at a pawn shop, 0.85 for some online buyers).

The same cent-rounding is applied to per-gram, per-troy-ounce, and per-troy-pound quotes so table output stays consistent with a UI.

When you need live prices

This library stops at the arithmetic. If you want the same karat and unit conversion with a regularly updated spot price in the browser, there is a scrap gold calculator that applies these ratios without an account.

License

MIT

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0 111 8/30/2026