I need to convert C++ double precision numbers into strings in such a way that sorting the strings alphabetically will deliver the same order as sorting the numbers arithmetically.
I'm considering using a fixed size integer and decimal part. For instance:
1.5 < 11.0, as well as alphabetically 0001.5000 < 0011.0000
However, this method has several problems (such as range limitation). Is there any better method? Does converting doubles into bitsets meet the requirements?
Aucun commentaire:
Enregistrer un commentaire