• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Adobe ANE ProductStore, price Tiers, weird values

New Here ,
Sep 12, 2015 Sep 12, 2015

Copy link to clipboard

Copied

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

TOPICS
Development

Views

364

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Engaged , Sep 14, 2015 Sep 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 a

...

Votes

Translate

Translate
Engaged ,
Sep 14, 2015 Sep 14, 2015

Copy link to clipboard

Copied

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).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 14, 2015 Sep 14, 2015

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Sep 14, 2015 Sep 14, 2015

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines