Lcc printf floating point

I have the following program:

#include <stdio.h> int main(int args, char *argv[]) { printf("%f\n", 0.99999); printf("%e\n", 0.99999); } 

Result:

 0.009990 9.999900e-001 

Why is the first number wrong? I am using Windows XP, the compiler "Logiciels Informatique lcc-win32 version 3.8. Compilation date: November 30, 2012 19:38:03".

+7
c floating-point windows-xp
source share
1 answer

This program is correct, and its output should be:

 0.999990 9.999900e-01 

or something very similar to that.

(You are not using args or argv , and the usual name for the first main parameter is argc , not args , but none of them is a problem that could affect your program behavior.)

It looks like you found a mistake in your implementation, perhaps in the runtime library, and not in the compiler itself. My short google searches did not display a link to this particular error (in fact, this was the first question).

I suggest contacting the maintainer of lcc-win; contact information is on the website . A brief description and a link to this question should contain enough information, at least for starters.

+2
source share

All Articles