Re: [webpayments] Expression of monetary amounts (#40)

> I'm not sure how this could be true. Do different JSON parsers interpret integers differently?

If they are large enough, sure.

node.js/Chrome/Firefox:

```js
console.log(JSON.parse('{"key": 123456789123456789}').key);
```

Result:

```
123456789123456780
```

Python:

```py
import json
print(json.loads('{"key": 123456789123456789}')['key'])
```

Result:

```
123456789123456789
```

PHP:

```php
<?php
echo json_decode('{"key": 123456789123456789}')->key;
?>
```

Result:

```
123456789123456789
```

Increase the number enough and Python will work just fine but PHP with start throwing integer overflow errors. I didn't test any other parsers. I think we should serialize these numbers in a way that is guaranteed not to lose any precision. We could declare "X bits should be enough for any currency" or we could use a string and avoid that (potentially incorrect) assumption.

> Developers using ISO8583 have managed for some decades as I say.

Will they be the only developers using this new API?

---
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webpayments/issues/40#issuecomment-165935808

Received on Saturday, 19 December 2015 02:10:12 UTC