Instantly share code, notes, and snippets.

Embed
What would you like to do?
Currency Converter for the Indian Numbering System
class UnitIndianCurrency:Dimension {
static let rupees = UnitIndianCurrency(symbol: "rupees", converter: UnitConverterLinear(coefficient: 1.0))
static let hazar = UnitIndianCurrency(symbol: "hazar", converter: UnitConverterLinear(coefficient: 1000.0))
static let lahk = UnitIndianCurrency(symbol: "lahk", converter: UnitConverterLinear(coefficient: 100000.0))
static let crore = UnitIndianCurrency(symbol: "crore", converter: UnitConverterLinear(coefficient: 10000000.0))
static let arab = UnitIndianCurrency(symbol: "arab", converter: UnitConverterLinear(coefficient: 1000000000.0))
static let kharab = UnitIndianCurrency(symbol: "kharab", converter: UnitConverterLinear(coefficient: 100000000000.0))
static let lahkCrore = UnitIndianCurrency(symbol: "lahk crore", converter: UnitConverterLinear(coefficient: 1000000000000.0))
static let neel = UnitIndianCurrency(symbol: "neel", converter: UnitConverterLinear(coefficient: 10000000000000.0))
static let padam = UnitIndianCurrency(symbol: "padam", converter: UnitConverterLinear(coefficient: 1000000000000000.0))
static let shankh = UnitIndianCurrency(symbol: "shankh", converter: UnitConverterLinear(coefficient: 1000000000000000000.0))
override static func baseUnit() -> UnitIndianCurrency {
return self.rupees
}
}
@stuartbreckenridge

This comment has been minimized.

Owner

stuartbreckenridge commented Jul 22, 2016

let oneLahk = Measurement(value: 1.0, unit: UnitIndianCurrency.lahk) // 1.0 lahk
let rupeeValue = oneLahk.converted(to: .rupees) // 100000 rupees

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment