Thread overview
float/double to string (pure nothrow @nogc)
Aug 08
vit
Aug 08
ketmar
Aug 08
vit
Aug 08
ketmar
August 08
Hello, is in phobos some function which convert float/double to string and is pure @nogc and nothrow?


August 08
On 8/8/18 1:08 PM, vit wrote:
> Hello, is in phobos some function which convert float/double to string and is pure @nogc and nothrow?
> 
> 

Not one that I can see. formattedWrite doesn't seem to be pure.

-Steve
August 08
vit wrote:

> Hello, is in phobos some function which convert float/double to string and is pure @nogc and nothrow?

i don't think that you can make it `pure`, but you certainly can make it `nothrow`, `@nogc` and ctfe-able. it's dangerous to go alone! take this[0].


[0] http://repo.or.cz/iv.d.git/blob_plain/HEAD:/ctfefloat.d
August 08
On Wednesday, 8 August 2018 at 17:40:11 UTC, ketmar wrote:
> vit wrote:
>
>> Hello, is in phobos some function which convert float/double to string and is pure @nogc and nothrow?
>
> i don't think that you can make it `pure`, but you certainly can make it `nothrow`, `@nogc` and ctfe-able. it's dangerous to go alone! take this[0].
>
>
> [0] http://repo.or.cz/iv.d.git/blob_plain/HEAD:/ctfefloat.d

thanks, that code can be modified to pure nothrow @nogc @safe.
Is that lib ok? Is little complicated...

August 08
On Wednesday, 8 August 2018 at 17:08:57 UTC, vit wrote:
> Hello, is in phobos some function which convert float/double to string and is pure @nogc and nothrow?

Short answer: no.
Long answer: https://issues.dlang.org/show_bug.cgi?id=17628
August 08
vit wrote:

> thanks, that code can be modified to pure nothrow @nogc @safe.
> Is that lib ok? Is little complicated...

converting float to string is a *very* complicated task. that lib is quite small for what it is doing ('cause it hacks around some... interesting cases). the *real* thing will be a LOT bigger.