POV-Ray : Newsgroups : povray.off-topic : All your radix are belong to us! : Re: All your radix are belong to us! Server Time
29 Jul 2024 22:23:26 EDT (-0400)
  Re: All your radix are belong to us!  
From: Warp
Date: 2 Aug 2011 14:03:47
Message: <4e383c02@news.povray.org>
Darren New <dne### [at] sanrrcom> wrote:
> I think C# actually came up with quite a sweet compromise. (Well, maybe not 
> came up with, maybe "stole", but it's pretty good anyway.)  You put in 
> something like

>     output.write("blah {0:x} blah {2:y} blah {1:0,000.00}", a, b, c);

  In C++ you could use the boost format library, which allows you to do
things like this:

    std::cout << boost::format("writing %1%, x=%2% : %3%-th try")
                 % "toto" % 40.23 % 50;

  (OTOH I'm guessing this is less efficient than the direct approach.)

> Last time I had to do something like that, I used

> typedef int MySpecialInt;
> #define MySpecialIntFmt "%i"

> and then

> printf("Here are " MySpecialIntFmt " integers", i);

  Which is inconvenient if you need to use some format specifiers (such
as printing at least 5 digits, with leading zeros).

-- 
                                                          - Warp


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.