From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16259 invoked by alias); 8 Jun 2004 10:17:46 -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 16212 invoked from network); 8 Jun 2004 10:17:34 -0000 Received: from unknown (HELO mail.uni-magdeburg.de) (141.44.1.10) by sourceware.org with SMTP; 8 Jun 2004 10:17:34 -0000 Received: from sunny.urz.uni-magdeburg.de ([141.44.8.7]) by mail.uni-magdeburg.de with esmtp (EXIM Version 4.30) for id 1BXdfV-0001YJ-P6; Tue, 08 Jun 2004 12:17:21 +0200 Received: from connect3.urz.uni-magdeburg.de (IDENT:Lb1WgpM93lATu2mNt2AXJRGsFF/F7Bf5@connect3.URZ.Uni-Magdeburg.DE [141.44.11.4]) by sunny.urz.uni-magdeburg.de (8.12.10/8.12.10) with ESMTP id i58AHGDR007825 for ; Tue, 8 Jun 2004 12:17:16 +0200 Received: (from bley@localhost) by connect3.urz.uni-magdeburg.de (8.11.6/8.11.6) id i58AHGM05286 for gcc-help@gcc.gnu.org; Tue, 8 Jun 2004 12:17:16 +0200 Date: Tue, 08 Jun 2004 10:17:00 -0000 From: Claudio Bley To: gcc-help@gcc.gnu.org Subject: Re: help needed Message-ID: <20040608101716.GA3568@connect3.urz.uni-magdeburg.de> Mail-Followup-To: Claudio Bley , gcc-help@gcc.gnu.org References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.1i X-Spam-Score: -4.9 (----) X-Spam-Report: ---- Start SpamAssassin results -4.9 points, 5.0 required; -4.9 BAYES_00 BODY: Bayesian spam probability is 0 to 1% [score: 0.0000] ---- End of SpamAssassin results X-Scan-Signature: 6e5f8897cd53297fcd2c4ee06c562b2f X-SW-Source: 2004-06/txt/msg00067.txt.bz2 Hello Naga, On Sat, Jun 05, 2004 at 07:55:40PM -0700, Naga Raju Thogiti wrote: > Hi, > I am writing C++ program for displaying a table of tangents given the > lower and upper limits. The program initially rounds off ( e.g if one > enters 29.58 and 30.33, it rounds off it to 29.6 and 30.3), and output the > result in a table form. I have this problem with displaying the table > completely and correctly, it was challenging for me to figure out where > was I going wrong? Can you please help me out with it. > > When I entered, 29.58 30.33 it stops at 30.2, for 32 34, it stops at 33.9 > but when I entered 84.14 84.44 and 89.44 89.48 it gives me correct table. At first, please note that this list is about the usage of or problems with GCC, the GNU Compiler Collection. Skimming through your post I haven't found the word gcc / g++ etc. not a single time. This makes me suspect that your problem would've been better addressed somewhere else. Anyway, to answer your question: You need to remember that floating point numbers are inherently imprecise and that you can't expect that if you add 0.1 to a floating point number that its value will increase exactly by 0.1 nor that 0.1 itself can be exactly represented as a floating point number. > //cout<<"\n\t "<((max_Value - min_Value) * 10)); i >= 0; --i) // ... A few notes about your code: You're using the old C++ headers. In new code you might want to use standard headers like 'iostream' instead of the antiquated 'iostream.h', 'cmath' instead of 'math.h' et cetera. > void main () This *needs* to be "int main(void)". > for (int j = 1;j<=100;j++) > { > cout<<"-"; > } You might find it easier (or at least shorter) to write 'cout << string ("-", 100);' instead of the above. Cheers. -- Claudio