Skip to main content
Participating Frequently
September 12, 2015
Answered

Adobe ANE ProductStore, price Tiers, weird values

  • September 12, 2015
  • 1 reply
  • 533 views

Hi

I have implemented the Adobe AIR IOS ProductStore ANE and its working ok bar the return values when querying the apps IAP products

Everything returns fine bar the IAP prices

2. title : Unlocked : Premium

priceLocale: en_IE@currency=EUR

price :2.9899999999999998

3. title : Unlocked : Standard

priceLocale: en_IE@currency=EUR

price :1.9899999999999998

As you can see, the IAP products use Tier 2 and 3 pricing, which should be 1.99 and 2.99 - any ideas why it is returning the above ?

Thanks

Pete

This topic has been closed for replies.
Correct answer kheftel

I have not used this ANE but one simple solution would be to round the values to two decimal places (I believe toFixed(2) would do it?). At least with the two examples you provided, this would fix your problem.

Binary-based floating-point math like modern processors use can't perfectly represent some decimal numbers, it may just be a rounding error that is inherent in the IEEE floating-point standard in every modern cpu. Similar to how 1/3 in decimals requires infinite digits, some numbers that are easy to represent in decimal are hard to represent by binary computers (which they all are).

1 reply

kheftel
kheftelCorrect answer
Inspiring
September 14, 2015

I have not used this ANE but one simple solution would be to round the values to two decimal places (I believe toFixed(2) would do it?). At least with the two examples you provided, this would fix your problem.

Binary-based floating-point math like modern processors use can't perfectly represent some decimal numbers, it may just be a rounding error that is inherent in the IEEE floating-point standard in every modern cpu. Similar to how 1/3 in decimals requires infinite digits, some numbers that are easy to represent in decimal are hard to represent by binary computers (which they all are).

PeteDevFFAuthor
Participating Frequently
September 14, 2015

Thanks, I used the toFixed function . Still it should really be done on the server side.

kheftel
Inspiring
September 14, 2015

yeah, financial calculations can get tricky fast, combined with the limitations of IEEE floating point.