April 04, 2011 Re: Static array size limit | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On 2011-04-04 06:37, Steven Schveighoffer wrote:
> On Sat, 02 Apr 2011 10:45:51 -0400, bearophile <bearophileHUGS@lycos.com>
>
> wrote:
> > simendsjo:
> >> http://digitalmars.com/d/2.0/arrays.html says static arrays are
> >> limited to 16mb, but I can only allocate 1mb.
> >> My fault, or bug?
> >
> > It accepts 4_000_000 ints, but not (16 * 1024 * 1024) / int.sizeof = 4_194_304 ints. I don't know why it's designed this way... I'd like 4_194_304 ints.
>
> That would be 16 MiB.
>
> http://en.wikipedia.org/wiki/Mebibyte
Most of the time that anyone talks about megabytes, they mean mebibytes, so I think that it's unrealistic to expect that anyone is going to see 16MB and think that it means 16_000_000 bytes reather than 16_777_216 bytes.
- Jonathan M Davis
|
April 05, 2011 Re: Static array size limit | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis | And it seems also Walter is meaning mebibytes: enum size = (16*1024*1024)/int.sizeof; static assert(!__traits(compiles, int[size])); static assert(__traits(compiles, int[size-1])); |
Copyright © 1999-2021 by the D Language Foundation