Octal Literals
H. S. Teoh
hsteoh at quickfur.ath.cx
Wed Jul 18 10:26:21 PDT 2012
On Wed, Jul 18, 2012 at 05:06:21PM +0200, Simen Kjaeraas wrote:
> On Wed, 18 Jul 2012 16:45:58 +0200, Dave X. <dxuhuang at gmail.com> wrote:
>
> >Not that this really matters, but out of curiosity, how does this
> >template work?
>
> It converts the passed number to a string, then works on a digit at a
> time. Basically:
>
> foreach ( digit; number ) {
> if ( digit >= '0' && digit <= '9' )
> result = result * 8 + digit;
> }
[...]
And this is done at compile-time, so there is no runtime overhead (it
just becomes a constant like an actual literal).
T
--
"640K ought to be enough" -- Bill G., 1984. "The Internet is not a primary goal for PC usage" -- Bill G., 1995. "Linux has no impact on Microsoft's strategy" -- Bill G., 1999.
More information about the Digitalmars-d
mailing list