From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22976 invoked by alias); 27 Aug 2012 09:42:48 -0000 Received: (qmail 22967 invoked by uid 22791); 27 Aug 2012 09:42:47 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from hermes.csrv.ucy.ac.cy (HELO hermes.csrv.ucy.ac.cy) (194.42.13.180) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 27 Aug 2012 09:42:25 +0000 Received: from ucy.ac.cy ([127.0.0.1]) by hermes.csrv.ucy.ac.cy (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) with ESMTP id <0M9E007XBQW3IY30@hermes.csrv.ucy.ac.cy> for gcc-help@gcc.gnu.org; Mon, 27 Aug 2012 12:40:51 +0300 (EEST) Received: from [62.228.97.248] by hermes.csrv.ucy.ac.cy (mshttpd); Mon, 27 Aug 2012 12:40:51 +0300 Date: Mon, 27 Aug 2012 11:16:00 -0000 From: Anna Sidera Subject: how to use malloc to reserve space for 1 million floats To: gcc-help@gcc.gnu.org Message-id: MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT Content-disposition: inline X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2012-08/txt/msg00264.txt.bz2 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