Hacker News new | past | comments | ask | show | jobs | submit login

I agree about clearing up ambiguity. But I'm not convinced that there's a best way to answer it without context.

For instance, enter "1%" into Wolfram and it'll tell you it's 1/100. Do the same for 3% and it'll tell you it's 3/100. Now ask it to add those 2 fractions, and it'll obviously give you 4/100 - which it reports can be expressed as 4%.

These are supposed to be alternate representations of the same thing, so arguably the answer shouldn't be different.




Though to be fair in normal usage 100 + 3% would be 103. I feel there is an implicit "of it" after 3% which you wouldn't expect with 3/100. I think it's accountant maths.


basically the « % » symbol in 3% is a fraction notation or it’s a type notation you can overload the add operation like below.

Add(int x, Percent y) = x + (y/100)*x


I agree, choosing a single answer at all is a bit weird here.


but `+` is polymorphic in the inputs as is `print`

just because `print` does one thing doesn't really mean `+` is constrained in the same way


Right, I'm just saying I think it's reasonable to expect + to be kind of isomorphic with different representations of the same thing.

Let's say f(x) gives some alternate representation of x. Then f(3) + f(1) should be equal to f(3 + 1). Under this interpretation, f(3%) = 3/100 etc, so that 3% + 1% = 4%.

But you could certainly argue that the idea of equating 3% with 3/100 is simply wrong. I like it because I like to think of "per" as meaning "divided by", and we generally use it that way when we use units like "metres per second = m/s = ms^(-1)".




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: