Closed oovm closed 1 year ago
Well, sorry, seems not work with no-std
Thanks for your contribution, but the implementation seems over-complicate for me. Do you have any specific reason to serialize the rational number as a struct with three parts? I was planning to serialize the rational number just as a pair of integers.
Besides, you can take a look at #11, where I listed all thirdparty crates I planned to support, so you don't have to implement them yourselves.
How about dividing into the following three binary representations?
[ ]
=> 0 / 1[i64, bytes<numerator>]
=> numerator / 1[i64, bytes<numerator>, u64, bytes<denominator>]
=> numerator / denominatorI don't think we need to handle the VLQ implementation ourselves, it could be handled by serializers like the postcard
. I already have serde
support for UBig
and IBig
, we should reuse the implementation of that. (Although I am planning to refactor it to use byte array instead of the word array which is currently used).
What I have planned for the (binary) serialization formats is:
UBig
serialized as a byte array (with given length)IBig
serialized as a byte array with the sign stored in the last byteRBig
serialized as a (named) tuple of (UBig, IBig)
FBig
serialized as a (named) tuple of (IBig, isize, usize)
For text serialization, I would just use the format result of each type.
serde
support for dashu-float
and dashu-ratio
has been added in https://github.com/cmpute/dashu/commit/d184f7cbb7654ccad692d7ff14d88c8e9f333e67, the improvements on serializing UBig
and IBig
will be added after releasing the next minor version, because that is a break change.
Thanks for your help but I will close this issue for now.