Hello everyone Here I am again with my little study project -
I have some BigDecimal fields in my table ServiceProvisions, like *BigDecimal :weekly_charge, :size => [18,4]* The values are returned as BigDecimals: *irb(main):015:0> DB[:service_provisions].first[:weekly_charge] * *=> #<BigDecimal:1732380,'0.22E0',9(18)>* and then I add dataset aggregation methods to the model for every decimal field that I have: *ServiceProvision.columns.each do |column_name|* * if ServiceProvision.db_schema[column_name][:type] == :decimal* * ServiceProvision.def_dataset_method(column_name) do* * sum(column_name)* * end* * end* *end* * * The aggregation function sum however returns a Float: *irb(main):019:0> DB[:service_provisions].sum(:weekly_charge).class* *=> Float* The question is does Sequel add them all up as BigDecimal values and *then*converts to Float or does it convert *first* and then adds them up? I believe this can make a difference to the precision of my output. Best regards, Ollie -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/sequel-talk/-/bsdJv34l3PQJ. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en.
