Highlighted

Adobe ANE ProductStore, price Tiers, weird values

New Here ,
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

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

TOPICS
Development

Views

265

Likes

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

Adobe ANE ProductStore, price Tiers, weird values

New Here ,
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

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

TOPICS
Development

Views

266

Likes

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
Sep 12, 2015 0
Engaged ,
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).

Likes

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
Reply
Loading...
Sep 14, 2015 0
New Here ,
Sep 14, 2015

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...
Sep 14, 2015 0
kheftel LATEST
Engaged ,
Sep 14, 2015

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...
Sep 14, 2015 0