converting numbers to strings and back

Derek Parnell derek at psych.ward
Sat Oct 6 14:37:59 PDT 2007


On Sat, 6 Oct 2007 18:43:21 +0200, dominik wrote:

> "Daniel Keep" <daniel.keep.lists at gmail.com> wrote in message 
> news:fe8dbp$v10$1 at digitalmars.com...
>> That's because you're trying to assign a constant type into a mutable
>> type.  Which is what the compiler is telling you.  Either use 'auto' for
>> the storage class, or explicit assign it to a 'string' (or const(char)[]
>> if you really feel like it).
> 
> thanks, auto did it - and I think I like auto from now on.
> 
>> Well, line 11 was "writefln(cTest);", so I assume you've changed
>> something, so I can't really help since I don't know what you've got any
>> more.
> 
> here is the deal - 2.005
> -----------------------------
> import std.stdio;
> import std.string;
> import std.conv;
> 
> void main(char[][] args) {
> 
>  float fFloat = 214.4;
>  float fBack = 0;
>  float fTo = 0;
> 
>  auto cTest = std.string.toString(fFloat); // Works!
>  writefln(cTest);
> 
>  fBack = toFloat(cTest); // Works too!
>  writefln(fBack);
> 
>  fTo = to!(float)(cTest); // this does not work! to undefined
> 
> }
> -----------------------------

I'm not having any problems with this (2.005). 

I tried you original code  (changing 'char[] cTest' to 'string cTest') and
it worked fine.

I tried the code above without changing anything and that too worked fine.
This makes me think that you have got an environment issue. Could it be
that the import search path is still pointing to DMD v1?



-- 
Derek Parnell
Melbourne, Australia
skype: derek.j.parnell


More information about the Digitalmars-d-learn mailing list