Mail Archives: djgpp/1999/03/07/20:55:58

From: Victor Senderov <victor DOT bg AT usa DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Problem with floats
Date: Sun, 07 Mar 1999 20:26:17 -0500
Organization: Posted via RemarQ, - Discussions start here!
Lines: 20
Message-ID: <>
Mime-Version: 1.0
X-Trace: 920856390 FQHDYQB2I4929D18DC
X-Complaints-To: newsabuse AT remarQ DOT com
X-Mailer: Mozilla 4.05 [en] (Win95; I)
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I wrote a test a program in order to see how djgpp will display a float
and was puzzled by the following:

#include <iomanip.h>
#include <iostream.h>
int main()
 cout << setprecision(25);
 double test = 37000.95000;
 cout << test;
 return 0;

Output : 37000.94999999999708961695
Can anybody explain why it outputs something so incorrect? Also, I
compiled this under other compiler and it worked ok -- the other
compiler displayed 37000.95

- Raw text -

  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019