On Tuesday, November 21, 2017 at 8:05:57 AM UTC+7, Vonpupp wrote:
>
> I wonder, *is there a way to limit the decimal places? *I tried with the
> Python Decimal's get_context (if I remember correctly).
>
In the Source I wrote for openexchange (currencies), I limit the decimal
places explicitly. The precision is artificially caused by conversion from
float to Decimal (so something like 1.2345 turns into
1.234500000000000000000000000001) so I was fine just brute force removing
it.
The way you do it with Decimal is the quantize method, not get_context. so
something like:
price = D(response['rates'][to_currency]).quantize(D('1.000000'))
--
You received this message because you are subscribed to the Google Groups
"Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/beancount/38f0e5fc-65ea-40e7-a8d9-bb83095c9fd1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.