• @Hadriscus@lemm.ee
    link
    fedilink
    82 days ago

    I know nothing about javascript, what is wrong with using + for math? perhaps naively, I’d say it looks suited for the job

      • @bitjunkie@lemmy.world
        link
        fedilink
        0
        edit-2
        2 days ago

        Point taken but the one I use is only ~200k for the whole package, ~11k for the actual file that gets loaded

    • @Quibblekrust@thelemmy.club
      link
      fedilink
      English
      62 days ago

      It’s much better to make your own function that uses bitwise operations to do addition.

      function add(a, b) {
          while (b !== 0) {
              // Calculate carry
              let carry = a & b;
      
              // Sum without carry
              a = a ^ b;
      
              // Shift carry to the left
              b = carry << 1;
          }
          return a;
      }
      

      (For certain definitions of better.)