4 ms·
If the maximum size of your number type is anywhere within 10x of your largest values you should definitely be using a larger number type. It’s just a way to wr
by woah 5y ago
If the maximum size of your number type is anywhere within 10x of your largest values you should definitely be using a larger number type. It’s just a way to write down a number. It’s like getting mad about the fact that negative numbers when written by hand require an extra character
- chriswarbo 5y ago> It’s like getting mad about the fact that negative numbers when written by hand require an extra character. Now that you mention it, that convention does make me mad. Not because I have to write an extra character, but due to operations getting mixed-up based on implied context. For example: Unary + is implicit: 3 = +3 Addition is written as juxtaposition: +2+5 = add(+2, +5) = +7. The first number can have an implicit sign, e.g. 2+5 = +2+5 "Subtraction" is a redundant operation; it's just addition involving a negative number: 8-3 = +8-3 = add(+8, -3) = +5. The nice thing about this perspective is that subtraction commutes: +8-3 = -3+8. What's annoying is that we also take juxtaposition to mean multiplication, and this flip-flops depending on implicit characters like unary '+'. For example: -8-3 = add(-8, -3) -8+3 = add(-8, +3) ab = multiply(a, b) 2a = multiply(2, a) a2 = multiply(2, a) (non-idiomatic) -2a = multiply(-2, a) a-2 = add(a, -2) This isn't just a problem when mixing variables with literals, since juxtaposition of literals also means multiplication (as long as they parse to separate numbers), e.g. '13' is a two-digit number, but: (1)(3) = multiply(1, 3) (-1)(-3) = multiply(-1, -3) -1-3 = add(-1, -3) -1(-3) = multiply(-1, -3) (-1)-3 = add(-1, -3) Note that we can do the same thing for multiplication and division, if we have a uniary reciprocal operator, e.g. ÷2 = 1/2. That way, division is just multiplication involving an inverse number, which commutes; e.g. 6÷2 = 6×÷2 = multiply(6, ÷2) = multiply(6, 1/2) = multiply(1/2, 6) = ÷2×6. This seems weirder than the case of addition/subtraction, probably because we already have the horizontal-bar notation for division, which seems even nicer. Note that the "÷" character itself is simply an inline approximation of the horizontal-bar notation (with placeholders above and below); the "foo/bar" notation is a more direct inline approximation (no placeholders, just 'tipping' the bar). Interestingly we don't use "bar\foo" to mean the same thing.
- potiuper 5y agoPartial application of the binary grouping operators with the first operand implicit does not have to stop at division: https://news.ycombinator.com/item?id=25278021 https://news.ycombinator.com/item?id=25278021