1. 6

  2. 3

    I am really not a fan of the “considered harmful” trope that people seem to love now, and the reasons presented here (matching ASR and a vague notion of “singularity”) are not motivations I find especially convincing, but I do agree with the pragmatic reasoning in the appendix thing: floored division/modulus makes array indexing a lot easier. I end up doing a lot of

    int idx = v % list.size();
    if (v < 0) v += list.size();
    return list[idx];

    When it sure would be nice to do list[v % list.size()]. I do wonder what the reasoning behind the default of symmetric division is; this article doesn’t get into it much, only focusing on the downsides, but I feel like smart people made this decision and they must have had their reasons, too.

    1. 4

      Personally I use floored division - but I get the reasoning. This will be surprising to some people:

      Math.floor(-7 / 3);

      versus the current status quo:

      Math.trunc(-7 / 3);
      1. 2

        Oh right, of course. Put another way, symmetric division has the property that it is the truncation of the proper real-number result, because truncation as an operation “rounds” towards zero. Thanks!