Gem Exchange: What is wrong with this?
Web Programming Lead
One decimal place is ok, two starts getting into the limitations of IEEE floats and the calls to the API get turned into nonsense.
Thus a request for 80.82 gold worth of gems returns “2” instead of something sensical. The trade happens entirely on the server and will deduct/deposit the correct amounts, it just won’t match up with the now-goofy UI state.
One decimal place is ok, two starts getting into the limitations of IEEE floats and the calls to the API get turned into nonsense.
Thus a request for 80.82 gold worth of gems returns “2” instead of something sensical. The trade happens entirely on the server and will deduct/deposit the correct amounts, it just won’t match up with the now-goofy UI state.
Right, it is so easy to forget that anything in the trading post window is actually a web based fronted / sub-application. Props for managing to make it look so “native” in terms of the games aesthetic (I am guessing the overall art style of the game helps a lot).
So, just a quick question then why isn’t the custom exchange three separate inputs for different types of coins like it is everywhere else in the trading post?
Edit: or alternatively, why does the custom exchange ask for the desired gold amount rather than the number of gems to trade away (in an ideal world we would have the choice between both inputs, but that could get tricky to keep in sync if both inputs remain editable).
(edited by Crise.9401)
One decimal place is ok, two starts getting into the limitations of IEEE floats and the calls to the API get turned into nonsense.
Might I recommend doubles…
One decimal place is ok, two starts getting into the limitations of IEEE floats and the calls to the API get turned into nonsense.
Might I recommend doubles…
I am guessing whatever they use to encode and decode the requests is the the source of this not being as easy as changing the type. I haven’t looked at the exact specifications for JSON or JavaScript in a long time, but if memory serves most parsers do indeed treat JSON Number type exclusively as float.
The easier solution is likely to either change the currency exchange API to use three distinct inputs for currency like all the rest of the traiding post inputs or limit the precision of the current input to one decimal place.
Edit: a third option is of course to use a numeric string that the server then converts to double after the JSON has been decoded serverside but that borders on a hacky workaround.
(edited by Crise.9401)
Pat Cavit.9234One decimal place is ok, two starts getting into the limitations of IEEE floats and the calls to the API get turned into nonsense.
?
Maybe I’m missing something here, but even single precision IEEE is good for 7.2 digits
(1 part in 2^24).
GemQty = ExchRate * GoldQty should be good to 6.9 digits.
Even calculating the exchange rate in single precision
(ie, ExchRate = 0.85*TPGemStockpile/TPGoldStockpile) should yield 6.0 digits.
On a possibly related note, a few months ago I posted on what appeared to be a back end rounding error: https://forum-en.gw2archive.eu/forum/support/bugs/TP-currency-xchg-rounding-error (to summarize: I bought 1 gem with gold and was charged approximately 150% of the current exchange rate). Another player suggested this was intentional (buying more gems gave you a volume discount), but since it was only noticeable for very small quantities of gems, I find that hard to believe.