Closed wildthink closed 8 years ago
Hi @wildthink - thanks for the feedback!
You're are absolutely correct, this should be the expected behavior.
And it should work - here is the code and the tests for that code.
Which means if it doesn't work there is a bug somewhere? Can you share your line of code?
Yes, that is correct for the Decimal but shouldn't the same Money -> Money operations not be provided / supported? Rather I would think they should be replaced by something like the following instead.
public func multiplyBy(other: IntegerLiteralType) -> _Money {
return _Money(decimal.multiplyBy(other))
}
etc.
Well, the operators are defined for all types which conform to DecimalNumberType
, and the tests are explicitly testing that for CNY
which is a _Money
type. So... it should definitely work. Are you using integer literals or integer values - because that might be the issue. If you could screen grab the bit of your code which isn't compiling with the error that would be helpful.
Hey, @wildthink I just double checked this with the latest version, v1.6.1:
let someMoney: GBP = 100.00
let multiplier = 2.5
let moreMoney = multiplier * someMoney * 3.5
print("You have even more money: \(moreMoney)")
which gives me:
You have even more money: £875.00
This illustrates multiplying money types by an float and a float literal. The same works with integers.
Happy to help you if you have issues with this, just get back to me. I'm going to close this for now however.
Shouldn't the operations support
$11.50 * 10
and not$11.50 * $10
? You want the same units with addition and subtraction but it doesn't make sense with multiplication and division.