The floating point number 10000000.0 is not correctly written to a new spreadsheet as it is displayed as -737418.24
in Excel 2000, OpenOffice.org 3.0.0, Excel 2007. It seems to be this number exactly as a small change to the number
results in the number being written correctly.
Here is the code to replicate the problem, and I have attached the output spreadsheet that was produced with the replication
code.
Harley Mackenzie
-----
#
# bug with spreadsheet gem 0.6.3.1
# Dr. Harley Mackenzie
# hjm@hardsoftware.com
#
require 'spreadsheet'
book = Spreadsheet::Workbook.new
sheet1 = book.create_worksheet
sheet1[0, 0] = (10000000).to_f # ERROR displayed as -737418.24
sheet1[1, 0] = (10000001).to_f # OK
sheet1[2, 0] = (9999999).to_f # OK
sheet1[3, 0] = (10000000).to_i # OK
sheet1[4, 0] = (100000000).to_f # OK
sheet1[5, 0] = (1000000000).to_f # OK
sheet1[6, 0] = (10000000000).to_f # OK
sheet1[7, 0] = (1000000).to_f #
sheet1[8, 0] = (100000).to_f #
sheet1[9, 0] = (10000).to_f #
sheet1[10, 0] = (1000).to_f #
sheet1[11, 0] = (10000000.0).to_f # ERROR displayed as -737418.24
sheet1[12, 0] = (10000000.1).to_f # OK
sheet1[13, 0] = (10000000.01).to_f # OK
sheet1[14, 0] = (10000000.001).to_f # OK
book.write './bug.xls'
|