You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current decimal serialization in Cosmos SDK does not preserve numeric ordering when used in Collections, which leads to incorrect iteration results. The issue arises because Collections sort decimals based on their string representation rather than their numeric values.
Is there an existing issue for this?
What happened?
Issue Description
The current decimal serialization in Cosmos SDK does not preserve numeric ordering when used in Collections, which leads to incorrect iteration results. The issue arises because Collections sort decimals based on their string representation rather than their numeric values.
Current Behavior
The current implementation (
cosmos-sdk/math/dec.go
Line 426 in f9bb180
This leads to counter-intuitive results when:
Expected Behavior
Collections should iterate through decimals in their true numeric order. For example:
Proposed Solution
Implement an order-preserving binary encoding for decimals:
Use IEEE 754-like binary encoding format which naturally preserves numeric ordering
Cosmos SDK Version
cosmossdk.io/math
How to reproduce?
No response
The text was updated successfully, but these errors were encountered: