Since scores in sorted set can be fractional values, Im storing score as a 64 bit floating point number which is f64 in rust,
the problem is while converting between 64 bit INT scores which are being used in geospatial scoring and storing them as f64 i think im losing precision due to which during encoding/decoding im getting coords that vary by more than 1e-6.
I have the same issue with Rust. The 6th decimal often deviates in the end result of the decoding process (u64 score input for decode is correct). The stage uses ZADD to add ‘hardcoded’ scores so encoding part can’t affect it.
I passed the stage but it required me to submit about 10 times in a row before I got lucky.
The precision requirement probably needs to be lowered.
I don’t think there’s anything you can do except wait for some kind of change to the tester (less precision is probably the only option).
The tester looks identical to the official redis implementation. The only difference I could spot is order of operations when converting degrees to radians but that shouldn’t make any significant difference.
I tried doing all calculations with very high precision decimal types but the result is the same. I also tried using a 100% identical implementation as the tester (adding an extra unnecessary conversion from degrees to radians which redis also does) but the result doesn’t change.
Maybe Go (tester) is doing something weird here with f64 calculations.
Yeah I just noticed you posted it in the other thread. That explains the deviation. The tester seems to be skipping the whole encode/decode part currently and expecting values that haven’t gone through the precision loss during encoding.
Since the free challenge is changing soon:
If you don’t want to wait use a high precision decimal type (eg. rust_decimal or num crate in rust or just Decimal in C#) for the decode part and submit 5-10 times until it passes. The later stages don’t have issues, although submitting them will take 5-10 tries again due to the geopos tests failing. It might be possible with normal f64 calculations but the difference to tester seemed to be slightly larger like that.