mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Bug 797106: Do a better job of converting decimal prices to rationals.
Use the Scheme rationalize method to convert the decimal numbers from Finance::Quote to ratinal numbers. This avoids rediculous precision like 8515625000000001/3906250000000000 for 2.18.
This commit is contained in:
parent
f22e30ba9e
commit
95aed30320
@ -404,12 +404,13 @@
|
|||||||
(else #f)))
|
(else #f)))
|
||||||
|
|
||||||
(if price
|
(if price
|
||||||
(set! price
|
;; The second argument to inexact->exact is chosen to give reasonable values
|
||||||
(double-to-gnc-numeric price
|
;; for prices between .12345e-9 and 12345678.87654
|
||||||
GNC-DENOM-AUTO
|
|
||||||
(logior GNC-DENOM-REDUCE
|
|
||||||
GNC-RND-NEVER))))
|
|
||||||
|
|
||||||
|
;; inexact->exact is probably not necessary but it can't hurt and is cheap.
|
||||||
|
(set! price
|
||||||
|
(gnc-scm-to-numeric
|
||||||
|
(rationalize (inexact->exact price) 1/1000000000000000))))
|
||||||
(if gnc-time
|
(if gnc-time
|
||||||
(set! gnc-time (timestr->time64 gnc-time time-zone))
|
(set! gnc-time (timestr->time64 gnc-time time-zone))
|
||||||
(set! gnc-time (gnc:get-today)))
|
(set! gnc-time (gnc:get-today)))
|
||||||
|
Loading…
Reference in New Issue
Block a user