# Size of long array

**URL:** <https://fortran-lang.discourse.group/t/size-of-long-array/3676>\
**Category:** Help\
**Created:** [June 6, 2022, 9:05pm UTC](https://fortran-lang.discourse.group/t/size-of-long-array/3676 "2022-06-06T21:05:08Z")\
**Posts on this page:** 1\
**Showing post:** 47

<div class="post-metadata">

**Author:** ![msz59](https://avatars.discourse-cdn.com/v4/letter/m/3d9bf3/32.png) [@msz59](https://fortran-lang.discourse.group/u/msz59)\
**Post date:** [June 7, 2022, 9:27pm UTC](https://fortran-lang.discourse.group/t/size-of-long-array/3676/47 "2022-06-07T21:27:07Z")

</div>

> [@ivanpribec](#):
>
> what @msz59 was suggesting, was to offer a “higher” precision accumulator

exactly so 🙂 My example actually shows two problems with summing a huge number of small values (random numbers are between 0 and 1). The first, obvious is roundoff error and the second is the finite _density_ of real values in the computer representation. In 4-bytes reals, above the magic value of 16777216, is it impossible to add a number less than one and get the result any different. Using higher precision accumulator helps with that. But, I must say, @ivanpribec’s trick with `sum(real(t,kind(1d0)))` is very smart. I would not guess that there would be no temporary array built (which would be a killer for GB-sized array)

_Edit:_ still, smart as it is, the trick depends fully on the smartness of compiler creators. It is by no means _guaranteed_. An optional `kind` parameter of `sum` could guarantee that.

---

_[View the full topic](https://fortran-lang.discourse.group/t/size-of-long-array/3676)._
