From: Gero Timann Newsgroups: comp.os.msdos.djgpp Subject: Re: Float question... Date: Mon, 12 Oct 1998 12:53:08 +0100 Organization: MediaCompany Goe Lines: 166 Message-ID: <3621EDA4.DF968070@mcis.deREMOVE_THIS> References: <3620BFD1 DOT 32265FF4 AT netrover DOT com> NNTP-Posting-Host: x145.mcis.de Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: news.mcis.de 908196831 3903 194.221.140.145 (12 Oct 1998 12:53:51 GMT) X-Complaints-To: news AT mcis DOT de NNTP-Posting-Date: 12 Oct 1998 12:53:51 GMT X-Mailer: Mozilla 4.05 [de]C-NECCK (Win95; I) To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Hi Nicolas ! Here the discription for printf from libc.inf : -------------------------------------------------------------------------------------- printf ====== Syntax ------ #include int printf(const char *format, ...); Description ----------- Sends formatted output from the arguments (...) to `stdout'. The format string contains regular characters to print, as well as conversion specifiers, which begin with a percent symbol. Each conversion speficier contains the following fields: * an optional flag, which may alter the conversion: `-' left-justify the field. `+' Force a `+' sign on positive numbers. `space' To leave a blank space where a plus or minus sign would have been. `#' Alternate conversion - prefix octal numbers with `0', hexadecimal numbers with `0x' or `0X', or force a trailing decimal point if a floating point conversion would have omitted it. `0' To pad numbers with leading zeros. * A field width specifier, which specifies the minimum width of the field. This may also be an asterisk (`*'), which means that the actual width will be obtained from the next argument. If the argument is negative, it supplies a `-' flag and a positive width. * An optional decimal point and a precision. This may also be an asterisk, but a negative argument for it indicates a precision of zero. The precision specifies the minimum number of digits to print for an integer, the number of fraction digits for a floating point number (max for `g' or `G', actual for others), or the maximum number of characters for a string. * An optional conversion qualifier, which may be `h' to specify `short', `l' to specify long ints, or `L' to specify long doubles. Long long type can be specified by `L' or `ll'. * The conversion type specifier: `c' A single character `d' A signed integer `D' A signed long integer `e' `E' A floating point number (double or long double). The exponent case matches the specifier case. The representation always has an exponent. `f' A floating point number (double or long double). The representation never has an exponent. `g' `G' A floating point number (double or long double). The exponent case matches the specifier case. The representation has an exponent if it needs one. `i' A signed integer. `n' The next argument is a pointer to an integer, and the number of characters generated so far is stored in that integer. `o' A unsigned integer, printed in base 8 instead of base 10. `p' A pointer. This is printed with an `x' specifier. `s' A `NULL'-terminated string. `u' An unsigned integer. `U' An unsigned long integer. `x' `X' An unsigned integer, printed in base 16 instead of base 10. The case of the letters used matches the specifier case. `%' A single percent symbol is printed. Return Value ------------ The number of characters written. Example ------- printf("%-3d %10.2f%% Percent of %s\n", index, per[index], name[index]); -------------------------------------------------------------------------------------- e.g, printf("%2.1f... or printf("%g... solves your problem. You can simplify your work, if you use the integrated development enviroment RHIDE. Here only pressing CRTL-F1 shows the informations above, when the cursor is in the word printf. Regards Gero Nicolas Blais schrieb: > Let's say I do this: const float version_of_game = 1.1; > When I do this : cprintf("The version: %f\n\r", version_of_game); > > Why will it print 1.10000, when I just want it to print 1.1? > > Thanks, Nicolas Blais -- ___________________________________________________________________ Dipl.Phys.Gero Timann Schülerstieg 20 37081 Göttingen Germany Tel./Fax: Germany-0551-96782 EMail: geti AT mcis DOT deREMOVE_THIS geti AT spock DOT physik3 DOT gwdg DOT deREMOVE_THIS geti AT online DOT deREMOVE_THIS ____________________________________________________________________