This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: how to use malloc to reserve space for 1 billion floats


On 28/08/12 05:58, Anna Sidera wrote:
> The system has 10 giga byte RAM.
>
> The command:
> uname -a
> gives the following output:
> Linux olympus 2.6.26-2-amd64 #1 SMP Wed Aug 19 22:33:18 UTC 2009 x86_64 GNU/Linux
> I think this means that the system is 64 bit.
It does.

> So you think that the command:
> int myvariable = 1000;
> float *myarray = malloc(pow(myvariable,3)*sizeof(float));
> will work if pow(myvariable,3) is smaller than 2 billion?
>
> Many Thanks,
> Anna
Yes. (the 2+e9 limit being roughly for the 7,45GB needed, not due to
malloc, to which you
could ask for even bigger amounts )


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]