Mail Archives: djgpp/2005/11/19/17:15:52
Martin Ambuhl wrote:
> Rod Pemberton wrote:
>
>> "Martin Ambuhl" <mambuhl AT earthlink DOT net> wrote in message
>> news:Iayff.1893$wf DOT 1283 AT newsread3 DOT news DOT atl DOT earthlink DOT net...
>>
>>> Rod Pemberton wrote:
>>>
>>>> "Martin Ambuhl" <mambuhl AT earthlink DOT net> wrote in message
>>>> news:Cxvff.2173$N45 DOT 189 AT newsread1 DOT news DOT atl DOT earthlink DOT net...
>>>>
>>>>
>>>>> Scott wrote:
>>>>>
>>>>>
>>>>>> On Fri, 18 Nov 2005 21:03:01 GMT, Martin Ambuhl
>>>>>> <mambuhl AT earthlink DOT net>
>>>>>> wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>>> printf() do not print long long integer.
>>>>>>>
>>>>>>>
>>>>>>> Show us how it fails. Here is an example of it working:
>>>>>>
>>>>>>
>>>>>> <snip example>
>>>>>>
>>>>>> Here's another example:
>>>>>>
>>>>>> printf("%llX\n", (long long)-1);
>>>>>
>>>>>
>>>>> If you mean an example of undefined behavior. The %llX specifier
>>>>> expects an unsigned long long; (long long)-1 is not unsigned.
>>>>
>>>>
>>>>
>>>> It's probably better to use capital L, instead of ll, since it works
>>
>>
>> with
>>
>>>> multiple compilers...
>>>> e.g.,
>>>>
>>>> sscanf(s,"%Lx",&value);
>>>>
>>>> printf("%Lu:%Lx\n",prime,counter);
>>>>
>>>
>>> Wrong. Since the L length modifier specifies that the argument is a
>>> long double, you've found another way to screw things up.
>>
>>
>>
>> No sir, I am correct. You are partially correct.
>
>
> Come off it. You claimed that
> > It's probably better to use capital L, instead of ll, since it works
> > with multiple compilers...
>
> This is a gross error. Read what you have quoted from the standard:
>
>> an optional L specifying that a following e , E , f , g , or G conversion
>> specifier applies to a long double argument. If an h , l , or L
>> appears with
>> any other conversion specifier, the behavior is undefined.
>
>
> Suggesting replacing a correct standard specifier with one with
> undefined behavior which is specific to particular implementations is a
> very peculiar way to targer "multiple compilers." You do a real
> disservice by doing such and should stop it. Your attempt to justify
> this anti-social suggestion contains the very language which shows you
> to be wrong.
Martin, please don't fight this one. From gcc's info on printf..
* 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'.
Clearly %d is int, %ld is long int and %lld and %Ld are long long int.
These are qualifiers of specifiers, not specifiers themselves. Clearly
%f specifies a double and qualified %Lf a long double.
--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
- Raw text -