Convert an amount of a unit to another of the same or different type.
IngredientIdβ The ID of the ingredient being converted (used for density lookup if needed)FromUnitβ The original unit (e.g.,"cup")ToUnitβ The target unit (e.g.,"tbsp"or"lb")Amountβ The numeric amount to convert (e.g.,1.5)
- If both
FromUnitandToUnitare the same type (e.g., volume β volume liketbspβcup),
β UseUnitConversionVolumelookup table - If crossing unit types (e.g.,
cupβlb),
β UseIngredientDensityBridge(requiresIngredientId) - Return the converted amount as a single numeric value
Convert:
- IngredientId =
"CHEDDAR" - FromUnit =
"cup" - ToUnit =
"lb" - Amount =
1
Result:
- Uses density bridge:
1 cupof cheddar =0.25 lb - Return:
0.25