Open denizzzka opened 8 years ago
client code:
import vibe.web.rest;
interface ITest
{
string getEchoText(string value_for_echo);
long getEchoBigint(long value_for_echo);
double getEchoFloat8(double value_for_echo);
}
auto m = new RestInterfaceClient!ITest(httpUrl);
assert(m.getEchoText("abc") == "abc");
assert(m.getEchoBigint(123456) == 123456);
assert(m.getEchoFloat8(123.456789) == 123.456789); // fail
@denizzzka this is due to the IEE 754 non-exact way with which float-point numbers are represented. Try the following on your machine:
double d = 123.456789;
writeln(d); // 123.457
@wilzbach I am doubt: try to add assert - it isn't fails in these case
assert(d == 123.456789);
writeln(d); // 123.457
writeln
just cuts output, IMHO. 6 digits is too small precision, so I think.
Trying to send by client double parameter with value 123.456789.
Client generates HTTP-request:
Where value is 123.457
Server also receives 123.457 value instead of 123.456789.