View mode: basic / threaded / horizontal-split · Log in · Help
November 18, 2010
Re: it's time to change how things are printed
On Thu, 18 Nov 2010 10:14:07 -0500, Steven Schveighoffer  
<schveiguy@yahoo.com> wrote:


> Should we create a DIP for this?  I'll volunteer to spearhead the effort  
> if people are on board.

I want to create a DIP, but it looks like I can't edit anything without a  
'valid' username.  However, when I put schveiguy as a username, it says  
that's not valid.  How do I get a valid username?

-Steve
November 18, 2010
Re: it's time to change how things are printed
Steven Schveighoffer Wrote:

> to!string(x);
> 

What's with text(x); ?
November 18, 2010
Re: it's time to change how things are printed
On 11/18/10 11:19 AM, Kagamin wrote:
> Steven Schveighoffer Wrote:
>
>> to!string(x);
>>
>
> What's with text(x); ?

text, wtext, and dtext accept a variable number of arguments of all 
types and create one string by concatenating to!(w|d|)string for all inputs.

Andrei
November 18, 2010
Re: it's time to change how things are printed
== Quote from Steven Schveighoffer (schveiguy@yahoo.com)'s article
> I want to create a DIP, but it looks like I can't edit anything without a
> 'valid' username.  However, when I put schveiguy as a username, it says
> that's not valid.  How do I get a valid username?
> -Steve


The username has to be mixed case for whatever reason (e.g., "SchveiGuy" or "StevenSchveighoffer").


From http://www.prowiki.org/wiki4d/wiki.cgi?WelcomeVisitor:
<<
You are welcome to edit pages in this wiki, but please enter your name on your "Preferences" page by clicking this link: Edit Preferences

There is no formal "account creation" required. Note, however, that the name you enter on the "Preferences" page must be all one word in "MixedCase"
or you will get an invalid username error. So "JimbobMcCranston" is ok, but "Jimbob McCranston" and "jimbob" are not.

The main reason for requiring a name to be set in the preferences is to reduce the amount of spam that has been put into this wiki by spam bots.
>>

jcc7
November 18, 2010
Re: it's time to change how things are printed
On Thu, 18 Nov 2010 17:01:03 +0000 (UTC)
"Lars T. Kyllingstad" <public@kyllingen.NOSPAMnet> wrote:

> That said, I also think toString is a bad name for this.  Especially 
> considering it will be used as an imperative, i.e.
> 
>   obj.toString(sink);

   obj.writeTo(sink);


Denis
-- -- -- -- -- -- --
vit esse estrany ☣

spir.wikidot.com
November 18, 2010
Re: it's time to change how things are printed
Lars T. Kyllingstad wrote:
> First of all, I think Andrei has already implemented this in the write*() 
> functions.  I use this toString() style also for std.complex.Complex, and 
> I can print complex numbers no problem.

Really? It doesn't work for me.

import std.complex;
import std.stdio;

void main()
{
    cdouble z2 = 10 + 1.5e-6i;
    Complex!(double) z;
    z.re = 10;
    z.im = 1.5e-6;
    writefln("z= %.16f z2 = %.16f", z, z2);
}

Prints:
z = 10+1.5e-06i z2 = 10.0000000000000000+0.0000015000000000i
November 18, 2010
Re: it's time to change how things are printed
On Thu, 18 Nov 2010 15:13:19 -0500, Don <nospam@nospam.com> wrote:

> Lars T. Kyllingstad wrote:
>> First of all, I think Andrei has already implemented this in the  
>> write*() functions.  I use this toString() style also for  
>> std.complex.Complex, and I can print complex numbers no problem.
>
> Really? It doesn't work for me.
>
> import std.complex;
> import std.stdio;
>
> void main()
> {
>      cdouble z2 = 10 + 1.5e-6i;
>      Complex!(double) z;
>      z.re = 10;
>      z.im = 1.5e-6;
>      writefln("z= %.16f z2 = %.16f", z, z2);
> }
>
> Prints:
> z = 10+1.5e-06i z2 = 10.0000000000000000+0.0000015000000000i

Haven't tested, but docs state that

"Note that complex numbers are floating point numbers, so the only valid  
format characters are 'e', 'f', 'g', 'a', and 's', where 's' gives the  
default behaviour. ***Positional parameters are not valid in this  
context.***"

I'd suggest trying one of those other format types without the numeric  
parts.

-Steve
November 18, 2010
Re: it's time to change how things are printed
Steven Schveighoffer wrote:
> On Thu, 18 Nov 2010 15:13:19 -0500, Don <nospam@nospam.com> wrote:
> 
>> Lars T. Kyllingstad wrote:
>>> First of all, I think Andrei has already implemented this in the 
>>> write*() functions.  I use this toString() style also for 
>>> std.complex.Complex, and I can print complex numbers no problem.
>>
>> Really? It doesn't work for me.
>>
>> import std.complex;
>> import std.stdio;
>>
>> void main()
>> {
>>      cdouble z2 = 10 + 1.5e-6i;
>>      Complex!(double) z;
>>      z.re = 10;
>>      z.im = 1.5e-6;
>>      writefln("z= %.16f z2 = %.16f", z, z2);
>> }
>>
>> Prints:
>> z = 10+1.5e-06i z2 = 10.0000000000000000+0.0000015000000000i
> 
> Haven't tested, but docs state that
> 
> "Note that complex numbers are floating point numbers, so the only valid 
> format characters are 'e', 'f', 'g', 'a', and 's', where 's' gives the 
> default behaviour. ***Positional parameters are not valid in this 
> context.***"
> 
> I'd suggest trying one of those other format types without the numeric 
> parts.
> 
> -Steve

    writefln("z = %f z2 = %f", z, z2);
z = 10+1.5e-06i z2 = 10.000000+0.000001i
    writefln("z = %e z2 = %e", z, z2);
z = 10+1.5e-06i z2 = 1.000000e+01+1.500000e-06i
    writefln("z = %a z2 = %a", z, z2);
z = 10+1.5e-06i z2 = 0x1.4p+3+0x1.92a737110e454p-20i
November 18, 2010
Re: it's time to change how things are printed
On Thu, 18 Nov 2010 16:25:28 -0500, Don <nospam@nospam.com> wrote:

> Steven Schveighoffer wrote:

>>  I'd suggest trying one of those other format types without the numeric  
>> parts.
>>  -Steve
>
>      writefln("z = %f z2 = %f", z, z2);
> z = 10+1.5e-06i z2 = 10.000000+0.000001i
>      writefln("z = %e z2 = %e", z, z2);
> z = 10+1.5e-06i z2 = 1.000000e+01+1.500000e-06i
>      writefln("z = %a z2 = %a", z, z2);
> z = 10+1.5e-06i z2 = 0x1.4p+3+0x1.92a737110e454p-20i

Then I agree, it doesn't work.

-Steve
November 18, 2010
Re: it's time to change how things are printed
On 11/18/10 1:25 PM, Don wrote:
> Steven Schveighoffer wrote:
>> On Thu, 18 Nov 2010 15:13:19 -0500, Don <nospam@nospam.com> wrote:
>>
>>> Lars T. Kyllingstad wrote:
>>>> First of all, I think Andrei has already implemented this in the
>>>> write*() functions. I use this toString() style also for
>>>> std.complex.Complex, and I can print complex numbers no problem.
>>>
>>> Really? It doesn't work for me.
>>>
>>> import std.complex;
>>> import std.stdio;
>>>
>>> void main()
>>> {
>>> cdouble z2 = 10 + 1.5e-6i;
>>> Complex!(double) z;
>>> z.re = 10;
>>> z.im = 1.5e-6;
>>> writefln("z= %.16f z2 = %.16f", z, z2);
>>> }
>>>
>>> Prints:
>>> z = 10+1.5e-06i z2 = 10.0000000000000000+0.0000015000000000i
>>
>> Haven't tested, but docs state that
>>
>> "Note that complex numbers are floating point numbers, so the only
>> valid format characters are 'e', 'f', 'g', 'a', and 's', where 's'
>> gives the default behaviour. ***Positional parameters are not valid in
>> this context.***"
>>
>> I'd suggest trying one of those other format types without the numeric
>> parts.
>>
>> -Steve
>
> writefln("z = %f z2 = %f", z, z2);
> z = 10+1.5e-06i z2 = 10.000000+0.000001i
> writefln("z = %e z2 = %e", z, z2);
> z = 10+1.5e-06i z2 = 1.000000e+01+1.500000e-06i
> writefln("z = %a z2 = %a", z, z2);
> z = 10+1.5e-06i z2 = 0x1.4p+3+0x1.92a737110e454p-20i

Clearly there's a bug in the formatting logic. Should be easy to fix, 
but I'm groping for time at the moment. Don, could you please 
bugzillize? Thanks.

Andrei
1 2 3
Top | Discussion index | About this forum | D home