fast_excel icon indicating copy to clipboard operation
fast_excel copied to clipboard

Floating point error for `FastExcel#date_num`

Open tientt-holistics opened this issue 1 year ago • 0 comments

Hi! First of all thanks for this gem!

There might be a floating point error for FastExcel#date_num in the latest version 0.5.0 Reproduce

time = Time.new("2016-09-01 00:00:00 +0700")
FastExcel.date_num(Time.new("2016-09-01 00:00:00 +0700"))

Expected

42370

Actual

42369.99999999999

This affects all outputted Excel files since it is being used in FastExcel::WorksheetExt#write_value. I understand there could be a performance trade-off here. But I would really like to have an option to explicitly decide between fast and precision.

Thank you in advance.

tientt-holistics avatar Jul 26 '24 04:07 tientt-holistics