-
Notifications
You must be signed in to change notification settings - Fork 590
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
Bug: json!(f32) cannot get right result #14180
Comments
It is "right" as defined by IEEE 754 and RFC 8259:
|
The main issue found is in the sink JSON format, where we first convert to JSON and then switch to the type of the target library, which may result in the RW being real1.1 and downstream being f32 1.10000023841858. Is this expected |
If the downstream type is also f32 (rather than f64 / numeric / string), it would be converted back to 1.1 rather than 1.100000023841858 (note that number in your question has one less 0). The next representable number after 1.1 (3f8ccccd) is 1.1000001 (3f8cccce):
|
Describe the bug
We used json!() in some places to convert f32 to json(such as sink's JsonEncoder). It will convert the f32 to f64 and then transform it into JSON, which may result in inaccurate values. (https://stackoverflow.com/questions/73871891/how-to-serialize-a-struct-containing-f32-using-serde-json)
example:
f32: 1.1 -> json: 1.100000023841858
Error message/log
No response
To Reproduce
No response
Expected behavior
No response
How did you deploy RisingWave?
No response
The version of RisingWave
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: