Hi,
Is it possible not to loose precision when sending double value ?
In the exemple below I have 44.000083 and the result I get from vibe is 44.0001.
It seems that it use the default to!string to represent double.
It seems to work find when sending values to vibe, I don't loose any precision.
import vibe.d;
import vibe.web.rest;
import std.stdio;
string _routes = "";
shared static this(){
auto router = new URLRouter;
router.get("/", &displayRoutes);
registerRestInterface(router, new MyAPIMock());
foreach(route; router.getAllRoutes()) {
_routes = _routes ~ route.to!string();
_routes = _routes ~ "\r\n";
}
auto settings = new HTTPServerSettings;
settings.port = 8080;
listenHTTP(settings, router);
}
void displayRoutes(HTTPServerRequest req,
HTTPServerResponse res) {
res.writeBody(_routes);
}
interface MyAPI {
@property double getDouble();
}
class MyAPIMock : MyAPI {
public:
override:
@property double getDouble()
{
double result = 44.000083;
return result;
}
}