The bug
When a float/double NBT tag is converted to string NBT while containing the floating point values of NaN or infinity, the resulting value is NaNf / NaNd and Infinityf / Infinityd.
However, when parsing SNBT, those values are read not as floats/doubles, but as strings. Therefore, a round-trip conversion leads to information loss with these values.
How to reproduce
/data modify storage test:test test set value 999e999f
/data get storage test:test test
/data modify storage test:test test set value Infinityf
/data get storage test:test test✔ The first command converts SNBT (999e999f) to an NBT float (infinity)
✔ The second command converts the NBT float (infinity) back to SNBT (Infinityf)
❌ The third command converts SNBT (Infinityf) to an NBT string ("Infinityf")
✔ The fourth command converts the NBT string ("Infinityf") back to SNBT ("Infinityf")
Another way to test this would be using the server data generator NBT <-> SNBT converters to see the round-trip transformation from infinity/NaN floating point tags to string tags
Comments 2
Since 25w10a, SNBT rejects writing floats that result in infinity, making these repro steps no longer work.
However, the following commands can still be used to observe how the game stringifies NaN:
execute positioned ~ -179769313486231580793728971405303415079934132710037826936173778980444968292764750946649017977587207096330286416692887910946555547851940402630657488671505820681908902000708383676273854845817711531764475730270069855571366959622842914819860834936475292719074168444365510704342711559699508093042880177904174497792 ~ run summon minecraft:eye_of_ender ~ ~179769313486231580793728971405303415079934132710037826936173778980444968292764750946649017977587207096330286416692887910946555547851940402630657488671505820681908902000708383676273854845817711531764475730270069855571366959622842914819860834936475292719074168444365510704342711559699508093042880177904174497792 ~ {UUID:[I;0,0,0,0]}
data modify storage test:test test set from entity 0-0-0-0-0 Pos[1]
data get storage test:test testSource: https://gist.github.com/intsuc/bada350358cc8f9cc12e68e32c4b6414
Can confirm that this is an issue. Also affects 20w51a.