delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2003/04/04/08:01:18

Newsgroups: comp.os.msdos.djgpp
Subject: Division isn't working?
From: Mylon <no AT way DOT com>
Message-ID: <Xns9353511EB990EMylonnoway@65.32.1.8>
User-Agent: Xnews/5.04.25
Lines: 21
Date: Fri, 04 Apr 2003 12:55:36 GMT
NNTP-Posting-Host: 24.92.193.18
X-Complaints-To: abuse AT rr DOT com
X-Trace: twister.tampabay.rr.com 1049460936 24.92.193.18 (Fri, 04 Apr 2003 07:55:36 EST)
NNTP-Posting-Date: Fri, 04 Apr 2003 07:55:36 EST
Organization: RoadRunner - Tampa Bay
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

On both my Win98 and WinXP machines (I compiled the code separately on each 
one for testing) trying to divide two numbers through use of the forward 
slash results in an almost cosistant 0.

For example, the code:

	float blah;
	blah = (1 / 10);
	printf("%f %f %f\n", blah, 0.5, (11 / 10) );

prints "0.000000 0.500000 0.000000"

while the code:

 	int blah;
	blah = (1 / 10);
	printf("%f %f %f\n", blah, 0.5, (1 / 2) );

prints "0.000000 0.000000 0.000000" (not even the .5 displays properly.)

What is the problem here?

- Raw text -


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