problem with std.variant rounding
Suliman via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Apr 28 09:24:55 PDT 2017
On Friday, 28 April 2017 at 15:45:25 UTC, Suliman wrote:
> I am using https://github.com/mysql-d/mysql-native
> It's return from DB variant data-type.
>
> My DB include value: 56.051151 (double type in DB)
>
> I need to extract it. I tried several variants:
>
> writeln(point[3].coerce!float);
> writeln(point[3].coerce!string);
> writeln(point[3].coerce!double);
>
> but all of them return me it as: 56.0512
>
> How to return exactly 56.051151 ?
import std.stdio;
import std.variant;
void main()
{
Variant b = 56.051151;
float x = b.coerce!float;
writeln(x);
}
>56.0512
More information about the Digitalmars-d-learn
mailing list