problem with std.variant rounding

Suliman via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue May 2 02:00:08 PDT 2017


On Tuesday, 2 May 2017 at 08:02:23 UTC, Suliman wrote:
> On Saturday, 29 April 2017 at 08:57:09 UTC, Petar Kirov 
> [ZombineDev] wrote:
>> On Friday, 28 April 2017 at 18:08:38 UTC, H. S. Teoh wrote:
>>> On Fri, Apr 28, 2017 at 04:42:28PM +0000, via 
>>> Digitalmars-d-learn wrote: [...]
>>>>         writefln(text("%.", i, "f"), x);
>>> [...]
>>>
>>> There's no need to use text() here:
>>>
>>> 	writefln("%.*f", i, x);
>>>
>>> does what you want.
>>>
>>>
>>> T
>>
>> Thanks, I missed the fact that * could be used for specifying 
>> the precision, in addition to the width.
>
> I need co concatenate string with variant type (I am doing SQL 
> query).
>
> What is the best way to put it? It's seems that if I am doing 
> simple `replace`
>
> string sql = "..."
> sql.replace(`37.72308`, 
> to!string(cargpspoint.lon)).replace(`55.47957`, 
> to!string(cargpspoint.lat))
>
> I am loosing accuracy. Is there any better way?

I did:
sql_distance.replace(`37.72308`, format("%f",cargpspoint.lon))

It's seems that it's work ok. But is there any better way, or 
it's ok?


More information about the Digitalmars-d-learn mailing list