Jump to page: 1 2
Thread overview
printf
Apr 18, 2003
Sean L. Palmer
Apr 18, 2003
John Reimer
Apr 18, 2003
Luna Kid
Apr 18, 2003
Luna Kid
Apr 18, 2003
John Reimer
Apr 18, 2003
Helmut Leitner
Apr 18, 2003
Sean L. Palmer
Apr 18, 2003
Helmut Leitner
Apr 18, 2003
Jonathan Andrew
Apr 18, 2003
Matthew Wilson
Apr 19, 2003
Sean L. Palmer
Apr 25, 2003
Ilya Minkov
Apr 18, 2003
Matthew Wilson
Apr 18, 2003
Matthew Wilson
Apr 18, 2003
Matthew Wilson
Apr 18, 2003
Nic Tiger
May 25, 2003
Walter
April 18, 2003
Ok, looks like printf is in fact in the stdio module.  It's also in object. I guess this isn't a problem.

However I seem unable to get printf to print out long (64-bit) ints, either
in decimal or in hex.

printf("big hex num = %lx\n",~0ul);
printf("big dec num = %lu\n",~0ul);

Am I being an idiot?

Sean


April 18, 2003
Sean L. Palmer wrote:

> Ok, looks like printf is in fact in the stdio module.  It's also in object.
> I guess this isn't a problem.
> 
> However I seem unable to get printf to print out long (64-bit) ints, either
> in decimal or in hex.
> 
> printf("big hex num = %lx\n",~0ul);
> printf("big dec num = %lu\n",~0ul);
> 
> Am I being an idiot?
> 
> Sean
> 
> 

Tried it as above on my system and worked fine for me. Used DMD 0.61.

-John

April 18, 2003

"Sean L. Palmer" wrote:
> 
> Ok, looks like printf is in fact in the stdio module.  It's also in object. I guess this isn't a problem.
> 
> However I seem unable to get printf to print out long (64-bit) ints, either
> in decimal or in hex.
> 
> printf("big hex num = %lx\n",~0ul);
> printf("big dec num = %lu\n",~0ul);
> 

I use
  printf("TimerCount  Start=%lld\n",t1);

--
Helmut Leitner    leitner@hls.via.at Graz, Austria   www.hls-software.com
April 18, 2003
"John Reimer" <jjreimer@telus.net> wrote in message news:b7ogrh$23g1$2@digitaldaemon.com...
> Sean L. Palmer wrote:
>
> > However I seem unable to get printf to print out long (64-bit) ints,
either
> > in decimal or in hex.
> >
> > printf("big hex num = %lx\n",~0ul);
> > printf("big dec num = %lu\n",~0ul);
>
> Tried it as above on my system and worked fine for me. Used DMD 0.61.

John, you mean you actually saw:

    big hex num = ffffffffffffffff
    big dec num = 18446744073709551615

Strange. I think, as Helmut wrote, one, indeed, needs
to use "ll" instead of "l". (I do use 0.61)

Cheers,
Sz.


April 18, 2003
> > > However I seem unable to get printf to print out long (64-bit) ints,
> either
> > > in decimal or in hex.
> > >
> > > printf("big hex num = %lx\n",~0ul);
> > > printf("big dec num = %lu\n",~0ul);
> >
> > Tried it as above on my system and worked fine for me. Used DMD 0.61.
>
> John, you mean you actually saw:
>
>     big hex num = ffffffffffffffff
>     big dec num = 18446744073709551615
>
> Strange. I think, as Helmut wrote, one, indeed, needs
> to use "ll" instead of "l". (I do use 0.61)

Which seems wrong, anyhow, I mean.

Sz.


April 18, 2003
Luna Kid wrote:
> "John Reimer" <jjreimer@telus.net> wrote in message
> news:b7ogrh$23g1$2@digitaldaemon.com...
> 
>>Sean L. Palmer wrote:
>>
>>
>>>However I seem unable to get printf to print out long (64-bit) ints,
> 
> either
> 
>>>in decimal or in hex.
>>>
>>>printf("big hex num = %lx\n",~0ul);
>>>printf("big dec num = %lu\n",~0ul);
>>
>>Tried it as above on my system and worked fine for me. Used DMD 0.61.
> 
> 
> John, you mean you actually saw:
> 
>     big hex num = ffffffffffffffff
>     big dec num = 18446744073709551615
> 
> Strange. I think, as Helmut wrote, one, indeed, needs
> to use "ll" instead of "l". (I do use 0.61)
> 
> Cheers,
> Sz.
> 
> 

oops, you're right. ha ha.  Stupid me. :-P

I guess I did only see the 32 bit version after all.

Thanks,

- John

April 18, 2003
%lld

"Sean L. Palmer" <palmer.sean@verizon.net> wrote in message news:b7odha$21hh$1@digitaldaemon.com...
> Ok, looks like printf is in fact in the stdio module.  It's also in
object.
> I guess this isn't a problem.
>
> However I seem unable to get printf to print out long (64-bit) ints,
either
> in decimal or in hex.
>
> printf("big hex num = %lx\n",~0ul);
> printf("big dec num = %lu\n",~0ul);
>
> Am I being an idiot?
>
> Sean
>
>


April 18, 2003
%lld is the correct one

Actually %ld will work, but truncate, and if you have multiple formatted expansions within a single block it'll be nasty.



"Sean L. Palmer" <palmer.sean@verizon.net> wrote in message news:b7odha$21hh$1@digitaldaemon.com...
> Ok, looks like printf is in fact in the stdio module.  It's also in
object.
> I guess this isn't a problem.
>
> However I seem unable to get printf to print out long (64-bit) ints,
either
> in decimal or in hex.
>
> printf("big hex num = %lx\n",~0ul);
> printf("big dec num = %lu\n",~0ul);
>
> Am I being an idiot?
>
> Sean
>
>



April 18, 2003
%lld is the correct one

Actually %ld will work, but truncate, and if you have multiple formatted expansions within a single block it'll be nasty.



"Sean L. Palmer" <palmer.sean@verizon.net> wrote in message news:b7odha$21hh$1@digitaldaemon.com...
> Ok, looks like printf is in fact in the stdio module.  It's also in
object.
> I guess this isn't a problem.
>
> However I seem unable to get printf to print out long (64-bit) ints,
either
> in decimal or in hex.
>
> printf("big hex num = %lx\n",~0ul);
> printf("big dec num = %lu\n",~0ul);
>
> Am I being an idiot?
>
> Sean
>
>



April 18, 2003
Write

printf("big hex num = %llx\n",~0ul);

instead (notice double 'l': %llx)
Since it works in DMC, I think it works in D.

"Sean L. Palmer" <palmer.sean@verizon.net> wrote in message news:b7odha$21hh$1@digitaldaemon.com...
> Ok, looks like printf is in fact in the stdio module.  It's also in
object.
> I guess this isn't a problem.
>
> However I seem unable to get printf to print out long (64-bit) ints,
either
> in decimal or in hex.
>
> printf("big hex num = %lx\n",~0ul);
> printf("big dec num = %lu\n",~0ul);
>
> Am I being an idiot?
>
> Sean
>
>


« First   ‹ Prev
1 2