Precision error on real (explicit) type:
Closed this issue · 3 comments
jacobloveless commented
It looks to me like something is off on the encoding of a real ...
A simple usecase:
var nodeq = require("node-q");
nodeq.connect({host: "localhost", port: 5000}, function(err, con) {
con.k("", nodeq.real(1.2345),function(err, res){
console.log(res)
});
});
Returns
>node t.js
1.2345000505447388
michaelwittig commented
I just tried:
var nodeq = require("node-q");
nodeq.connect({host: "localhost", port: 5000}, function(err, con) {
con.k("show", nodeq.real(1.2345),function(err, res){
console.log(res)
});
});
You will see a 1.2345e
in your q process.
I'm not sure if this is an issue or not... what are you try to achieve? only display the numbers?
jacobloveless commented
Sorry Michael, that was a bit unclear.
My question was about precision (on the JavaScript side).
A better example is below:
var nodeq = require("node-q");
nodeq.connect({host: "localhost", port: 5000}, function(err, con) {
con.k("{`e set x;x}",nodeq.real(1.2345),function(err, res){
console.log(res)
});
});
When I run this I get back a few trailing bits on the number (rather than padding with zeros)
node t.JS
1.2345000505447388
But I realize now this is actually the correct representation on the q side as well
q)\P 9999
q)e
1.2345000505447388e
So this is indeed not a bug , although for the life of me I'm not sure why these resolve to the numbers they do
michaelwittig commented
I gues that‘s the nature of floats.