Array reduction sum method with clause overflow protection

In reply to kuki2002:
why the casting with 48 and not 32.

  • sum the elements using a width of (32+4) = 36 bits
    Running the code, the result shows any number over 36 (upto 64) chosen for casting returns the correct sum of 10 (values chosen between 0-10).