public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* how to use malloc to reserve space for 1 million floats
@ 2012-08-27 11:16 Anna Sidera
  2012-08-27 16:15 ` Jonathan Wakely
  2012-08-27 16:23 ` Ángel González
  0 siblings, 2 replies; 5+ messages in thread
From: Anna Sidera @ 2012-08-27 11:16 UTC (permalink / raw)
  To: gcc-help

Hello,

I want to use the following command:

int myvariable = 1000;
float *myarray = malloc(pow(myvariable,3)*sizeof(float));

but I don't know if it will work because if sizeof(float) is equal to 4 then pow(myvariable,3)*sizeof(float) is equal to 4 billion which is larger than the maximum integer which is about 2 billion.

Can you tell me what is the right way to create an array of pow(myvariable,3) floats?

Many Thanks,
Anna

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-08-28 11:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-27 11:16 how to use malloc to reserve space for 1 million floats Anna Sidera
2012-08-27 16:15 ` Jonathan Wakely
2012-08-27 16:23 ` Ángel González
2012-08-28 11:18   ` how to use malloc to reserve space for 1 billion floats Anna Sidera
2012-08-28 13:12     ` Ángel González

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).