Re: [w3c/browser-payment-api] Why is details.total.amount.value not a number? (#301)

> Representing amounts in payments as floating point numbers is generally accepted as a bad idea. Amounts should be represented as decimals.

I agree with this.

When I wrote https://github.com/w3c/browser-payment-api/pull/256/commits/380c86274cfb967697d38b82847e5c0301b0d935 I considered defining it as a reference to HTML’s [_valid floating point number_](https://html.spec.whatwg.org/multipage/infrastructure.html#valid-floating-point-number) rather than minting the new [_valid decimal monetary value_](https://w3c.github.io/browser-payment-api/#dfn-valid-decimal-monetary-value) we now have.

But after discussion with others it became clear that using [_valid floating point number_](https://html.spec.whatwg.org/multipage/infrastructure.html#valid-floating-point-number) for monetary values is suboptimal.

Ideally I think what we should have a common definition for monetary values. So I opened https://github.com/whatwg/html/issues/2104 against the HTML spec to suggest adding it there.

If that change is made, then HTML’s [transaction-amount](https://html.spec.whatwg.org/multipage/forms.html#attr-fe-autocomplete-transaction-amount) definition could be updated to reference that “valid decimal monetary value” microsyntax rather than “valid floating point number”—and we could replace the definition we have in the Payment Request API spec with just a reference to that.

That’d be a better way to avoid duplication and to use a common definition for monetary amounts.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/browser-payment-api/issues/301#issuecomment-263067867

Received on Saturday, 26 November 2016 15:04:00 UTC