D - printf
- Sean L. Palmer (8/8) Apr 18 2003 Ok, looks like printf is in fact in the stdio module. It's also in obje...
- John Reimer (3/17) Apr 18 2003 Tried it as above on my system and worked fine for me. Used DMD 0.61.
- Luna Kid (10/17) Apr 18 2003 either
- Luna Kid (2/15) Apr 18 2003 Which seems wrong, anyhow, I mean.
- John Reimer (5/35) Apr 18 2003 oops, you're right. ha ha. Stupid me. :-P
- Helmut Leitner (6/16) Apr 18 2003 I use
- Sean L. Palmer (9/25) Apr 18 2003 Awesome. You see, this would be great to have on a webpage somewhere.
- Helmut Leitner (9/14) Apr 18 2003 We could write a page
- Jonathan Andrew (3/14) Apr 18 2003 I think the idea is to have a .toString property for all primitives even...
- Matthew Wilson (6/23) Apr 18 2003 That would be pretty inefficient, though, so would not be desirable for ...
- Sean L. Palmer (17/34) Apr 19 2003 No, that would be a bad idea, since unless it knew ahead of time how big...
- Ilya Minkov (22/28) Apr 25 2003 IIRC, there *is* a typesafe printf replacement in the DLI source written...
- Matthew Wilson (5/13) Apr 18 2003 %lld
- Matthew Wilson (7/15) Apr 18 2003 %lld is the correct one
- Matthew Wilson (7/15) Apr 18 2003 %lld is the correct one
- Nic Tiger (8/16) Apr 18 2003 Write
- Walter (4/8) May 25 2003 either
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
Apr 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? SeanTried it as above on my system and worked fine for me. Used DMD 0.61. -John
Apr 18 2003
"John Reimer" <jjreimer telus.net> wrote in message news:b7ogrh$23g1$2 digitaldaemon.com...Sean L. Palmer wrote:eitherHowever I seem unable to get printf to print out long (64-bit) ints,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.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.
Apr 18 2003
Which seems wrong, anyhow, I mean. Sz.eitherHowever I seem unable to get printf to print out long (64-bit) ints,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)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.
Apr 18 2003
Luna Kid wrote:"John Reimer" <jjreimer telus.net> wrote in message news:b7ogrh$23g1$2 digitaldaemon.com...oops, you're right. ha ha. Stupid me. :-P I guess I did only see the 32 bit version after all. Thanks, - JohnSean L. Palmer wrote:eitherHowever I seem unable to get printf to print out long (64-bit) ints,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.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.
Apr 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
Apr 18 2003
Awesome. You see, this would be great to have on a webpage somewhere. Along with %.s and everything else that's different from C. It'd be great if it just *knew* it was a 64-bit int automatically, and all you have to specify was the formatting. Sean "Helmut Leitner" <helmut.leitner chello.at> wrote in message news:3E9FD8CB.3FE42283 chello.at..."Sean L. Palmer" wrote:object.Ok, looks like printf is in fact in the stdio module. It's also ineitherI guess this isn't a problem. However I seem unable to get printf to print out long (64-bit) ints,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
Apr 18 2003
"Sean L. Palmer" wrote:Awesome. You see, this would be great to have on a webpage somewhere. Along with %.s and everything else that's different from C.We could write a page <http://www.prowiki.org/wiki4d/wiki.cgi?HowTo/printf>It'd be great if it just *knew* it was a 64-bit int automatically, and all you have to specify was the formatting.We could write a module for this. If D is any good, it shouldn't be a problem. -- Helmut Leitner leitner hls.via.at Graz, Austria www.hls-software.com
Apr 18 2003
"Sean L. Palmer" wrote:I think the idea is to have a .toString property for all primitives eventually, so you could just puts() everything concatenated together. -JonAwesome. You see, this would be great to have on a webpage somewhere. Along with %.s and everything else that's different from C.We could write a page <http://www.prowiki.org/wiki4d/wiki.cgi?HowTo/printf>It'd be great if it just *knew* it was a 64-bit int automatically, and all you have to specify was the formatting.We could write a module for this. If D is any good, it shouldn't be a problem.
Apr 18 2003
That would be pretty inefficient, though, so would not be desirable for all applications "Jonathan Andrew" <Jonathan_member pathlink.com> wrote in message news:b7psur$vhk$1 digitaldaemon.com...all"Sean L. Palmer" wrote:Awesome. You see, this would be great to have on a webpage somewhere. Along with %.s and everything else that's different from C.We could write a page <http://www.prowiki.org/wiki4d/wiki.cgi?HowTo/printf>It'd be great if it just *knew* it was a 64-bit int automatically, andeventually,I think the idea is to have a .toString property for all primitivesyou have to specify was the formatting.We could write a module for this. If D is any good, it shouldn't be a problem.so you could just puts() everything concatenated together. -Jon
Apr 18 2003
No, that would be a bad idea, since unless it knew ahead of time how big to make the staging area it'd end up allocating lots of memory during the concatenation, and doing more work than it has to. This is what streams are for. Streams != Arrays. Streams are more like a buffered circular queue. .toString is nice to have, also, btw. And some kind of stream that streams into a string (a string "staging area", or string "construction zone", if you will) would be quite handy. But for general I/O you really want a stream. Someone was working on something like this. There's a stream module in Phobos; I remember a long time ago it was broken, but I haven't tried it in ages. Anyone? Sean "Jonathan Andrew" <Jonathan_member pathlink.com> wrote in message news:b7psur$vhk$1 digitaldaemon.com...all"Sean L. Palmer" wrote:Awesome. You see, this would be great to have on a webpage somewhere. Along with %.s and everything else that's different from C.We could write a page <http://www.prowiki.org/wiki4d/wiki.cgi?HowTo/printf>It'd be great if it just *knew* it was a 64-bit int automatically, andeventually,I think the idea is to have a .toString property for all primitivesyou have to specify was the formatting.We could write a module for this. If D is any good, it shouldn't be a problem.so you could just puts() everything concatenated together. -Jon
Apr 19 2003
Helmut Leitner wrote:IIRC, there *is* a typesafe printf replacement in the DLI source written by Burton. It uses a "generic" type (struct with overloadings) to get the arguments. This is not inefficient, since you can make the methods of this type output directly. I don't remember whether there's any particular support for 64-bit int, it can be included easily anyway. The only problem with this approach is that if you make your own overloaded structs, how do you specify their output method? Besides, i somehow think efficiency is not that important: look, C++ offers iostreams, and most programmers actually use them, despite their inefficiency. The ones who don't, have their printf still available as they know it. However, i'm pretty much sure, that people really conserned with speed would abandon any varargs function and simply output their text part by part, with simple write or something alike. An interesting thing to have would be a printf which would allow for changing order of arguments, as it usually differs in various natural languages. This can be accomplished by requiering an associative array indexed by string as a second input. This is not necessarily a consern for Phobos though, unless until it has been actually implemented by a volunteer. -i.It'd be great if it just *knew* it was a 64-bit int automatically, and all you have to specify was the formatting.We could write a module for this. If D is any good, it shouldn't be a problem.
Apr 25 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 inobject.I guess this isn't a problem. However I seem unable to get printf to print out long (64-bit) ints,eitherin decimal or in hex. printf("big hex num = %lx\n",~0ul); printf("big dec num = %lu\n",~0ul); Am I being an idiot? Sean
Apr 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 inobject.I guess this isn't a problem. However I seem unable to get printf to print out long (64-bit) ints,eitherin decimal or in hex. printf("big hex num = %lx\n",~0ul); printf("big dec num = %lu\n",~0ul); Am I being an idiot? Sean
Apr 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 inobject.I guess this isn't a problem. However I seem unable to get printf to print out long (64-bit) ints,eitherin decimal or in hex. printf("big hex num = %lx\n",~0ul); printf("big dec num = %lu\n",~0ul); Am I being an idiot? Sean
Apr 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 inobject.I guess this isn't a problem. However I seem unable to get printf to print out long (64-bit) ints,eitherin decimal or in hex. printf("big hex num = %lx\n",~0ul); printf("big dec num = %lu\n",~0ul); Am I being an idiot? Sean
Apr 18 2003
"Sean L. Palmer" <palmer.sean verizon.net> wrote in message news:b7odha$21hh$1 digitaldaemon.com...However I seem unable to get printf to print out long (64-bit) ints,eitherin decimal or in hex. printf("big hex num = %lx\n",~0ul); printf("big dec num = %lu\n",~0ul);The format for D long's is %lld and %llu.
May 25 2003