the format for conversion of double in the function printf is
"%f" or "%lf" or both?
for example
printf("%f", (double)0.0);
printf("%lf", (double)0.0);
are both ok?
Good morning
Thank you 6 16695
it seems like that in c there is no need to print a double varible
with %lf format
%f is ok
but for long interger , u should use %ld
RoS wrote:
the format for conversion of double in the function printf is
"%f" or "%lf" or both?
for example
printf("%f", (double)0.0);
printf("%lf", (double)0.0);
are both ok?
Good morning
Thank you
RoS wrote:
the format for conversion of double in the function printf is
"%f" or "%lf" or both?
for example
printf("%f", (double)0.0);
printf("%lf", (double)0.0);
are both ok?
Yes they are equivalent, the l modifier has no effect for the f specifier.
--
Ian Collins.
Ian Collins wrote:
>
RoS wrote:
the format for conversion of double in the function printf is
"%f" or "%lf" or both?
for example
printf("%f", (double)0.0);
printf("%lf", (double)0.0);
are both ok?
Yes they are equivalent,
the l modifier has no effect for the f specifier.
That's the case for C99.
For C89,
a function call to printf is undefined
if "%lf" is the first argument.
--
pete
On Dec 3, 3:49 pm, pete <pfil...@mindspring.comwrote:
Ian Collins wrote:
RoS wrote:
the format for conversion of double in the function printf is
"%f" or "%lf" or both?
for example
printf("%f", (double)0.0);
printf("%lf", (double)0.0);
are both ok?
Yes they are equivalent,
the l modifier has no effect for the f specifier.
That's the case for C99.
For C89,
a function call to printf is undefined
if "%lf" is the first argument.
The first? "%d %lf" is not undefined? vi******@gmail.com writes:
On Dec 3, 3:49 pm, pete <pfil...@mindspring.comwrote:
>Ian Collins wrote:
RoS wrote:
the format for conversion of double in the function printf is
"%f" or "%lf" or both?
for example
printf("%f", (double)0.0);
printf("%lf", (double)0.0);
are both ok?
Yes they are equivalent,
the l modifier has no effect for the f specifier.
That's the case for C99. For C89, a function call to printf is undefined if "%lf" is the first argument.
The first? "%d %lf" is not undefined?
Yes, "%d %lf" is undefined for C89/C90's printf. He said "if", not
"if and only if".
(Incidentally, given printf("%d %lf", x, y), the first *argument*
isn't %d; it's the string "%d %ld".)
--
Keith Thompson (The_Other_Keith) <ks***@mib.org>
Looking for software development work in the San Diego area.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
In article <47***********@mindspring.com>,
pete <pf*****@mindspring.comwrote:
>Ian Collins wrote:
>> RoS wrote:
the format for conversion of double in the function printf is
"%f" or "%lf" or both?
>Yes they are equivalent, the l modifier has no effect for the f specifier.
>That's the case for C99. For C89, a function call to printf is undefined if "%lf" is the first argument.
And just to confuse matters, in C89, "%Lf" *is* defined and
indicates that the corresponding argument is long double .
--
"There are some ideas so wrong that only a very intelligent person
could believe in them." -- George Orwell This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: John Lenton |
last post by:
Is there any reason python's printf-style formatting is missing the
(C99) '%a' specifier?
I'm sorry if this has been asked and answered before; I can't find it
on google ('%a' is a very awkward...
|
by: J |
last post by:
Would anyone know if there a type tag to format a double?
I have f for floating point, but cannot find one for double.
|
by: google |
last post by:
first, a little background...
i have a C program which preprocesses some data, and then outputs the
results into a text file. that text file, in turn, is used as input
to a FORTRAN...
|
by: mdeaver2003 |
last post by:
I'm trying to output a double using a precision that
varies, governed by the value of a precision variable.
In C I can do it like this:
double pi = 3.14159;
int prec = 4;
printf( "%.*f",...
|
by: MC |
last post by:
In C, printf allows us to specify a runtime (non-constant) field width
of a formatted value by using the * character. Is there something
like that for System.String.Format? In C#, I find myself...
|
by: bobm2005 |
last post by:
Whatever format I try in Printf, an 'E' format number nearly always
has a leading non-zero:-
1.2345E7
-9.3456E8 etc.
Is it possible to force it (printf) always to have leading zero?
...
|
by: naunetr |
last post by:
in program below
#include <stdio.h>
int main()
{
int id = 123, io = 0123, ih = 0x123;
long ld = 1234567L, lo = 01234567l, lh = 0X1234567L;
float f = 123.456f;
double d = 01234.56789L;
|
by: JK |
last post by:
The following is a sample program I wrote..
float fTick = 0.0001;
float fLotSize = 100;
int iDeno = 10000;
double dVal;
double dInt;
dInt = fTick * fLotSize;
|
by: Adam |
last post by:
Hi,
I have a simple printf-like function:
int print(const char *format, ...)
{
char buffer;
va_list argptr;
int i;
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |