From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11555 invoked by alias); 9 Nov 2005 13:19:11 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 11537 invoked by uid 22791); 9 Nov 2005 13:19:08 -0000 Received: from web.keli.cz (HELO keli.cz) (84.244.113.227) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Wed, 09 Nov 2005 13:19:08 +0000 Received: from localhost (localhost [127.0.0.1]) by keli.cz (Postfix) with ESMTP id 49BAEA4CE18 for ; Wed, 9 Nov 2005 14:19:02 +0100 (CET) Received: from keli.cz ([127.0.0.1]) by localhost (web.keli.cz [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 09706-01 for ; Wed, 9 Nov 2005 14:18:59 +0100 (CET) Received: from [192.168.2.103] (mecir.clients.keli.cz [10.1.0.91]) by keli.cz (Postfix) with ESMTP id 9407EA4CE1C for ; Wed, 9 Nov 2005 14:18:59 +0100 (CET) Message-ID: <4371F73D.30201@mbox.vol.cz> Date: Wed, 09 Nov 2005 13:19:00 -0000 From: Ladislav Mecir User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) MIME-Version: 1.0 To: GCC Help Subject: Remainder ( % ) operator and GCC Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2005-11/txt/msg00124.txt.bz2 Hi all, new to this list. Could you give me an advice how to make the following program (and programs using many times the % operator) run reliably when compiled by GCC on different operating systems even when the user gives -1 as the B value? #include int main(int argc, char *argv[]) { int a = -2147483647; int b; printf ("The value of B: "); scanf ("%i", &b); printf ("%i %% %i: %i", a, b, (a - 1) % b); return 0; } TIA L.M.