www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - float/double to string (pure nothrow nogc)

reply vit <vit vit.vit> writes:
Hello, is in phobos some function which convert float/double to 
string and is pure  nogc and nothrow?
Aug 08 2018
next sibling parent Steven Schveighoffer <schveiguy gmail.com> writes:
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
Aug 08 2018
prev sibling next sibling parent reply ketmar <ketmar ketmar.no-ip.org> writes:
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
Aug 08 2018
parent reply vit <vit vit.vit> writes:
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...
Aug 08 2018
parent ketmar <ketmar ketmar.no-ip.org> writes:
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.
Aug 08 2018
prev sibling parent Paul Backus <snarwin gmail.com> writes:
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
Aug 08 2018