Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decode incorrect value - {"1":0.12} #41

Closed
JohnRSim opened this issue Oct 26, 2017 · 1 comment
Closed

Decode incorrect value - {"1":0.12} #41

JohnRSim opened this issue Oct 26, 2017 · 1 comment

Comments

@JohnRSim
Copy link

when I encode and then decode I'm not getting expected output..

let a = encode  = msgpack.encode,
	decode  = msgpack.decode;

const encodePack = encode({"1":0.12});
console.log(decode(encodePack));
//{ '1': 0.11999999731779099 }

Output -
{ '1': 0.11999999731779099 }

Expected -
{"1":0.12}

@llint
Copy link

llint commented Feb 11, 2018

This is floating point precision issue - because 0.12 cannot be precisely represented in the IEEE754 format - thus it's represented as the value as you see.

this is not a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants