Skip to content

Commit

Permalink
Add support for "1e6" as scientific notation
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Michal committed Jun 7, 2018
1 parent 4328221 commit 43f7ef5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/roo/excelx/cell/number.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def create_numeric(number)
when /\.0/
Float(number)
else
(number.include?('.') || (/\A[-+]?\d+E[-+]\d+\z/i =~ number)) ? Float(number) : Integer(number)
(number.include?('.') || (/\A[-+]?\d+E[-+]?\d+\z/i =~ number)) ? Float(number) : Integer(number)
end
end

Expand Down
5 changes: 5 additions & 0 deletions test/excelx/cell/test_number.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ def test_simple_scientific_notation
assert_kind_of(Float, cell.value)
end

def test_very_simple_scientific_notation
cell = Roo::Excelx::Cell::Number.new '1e6', nil, ['0'], nil, nil, nil
assert_kind_of(Float, cell.value)
end

def test_percent
cell = Roo::Excelx::Cell::Number.new '42.1', nil, ['0.00%'], nil, nil, nil
assert_kind_of(Float, cell.value)
Expand Down

0 comments on commit 43f7ef5

Please sign in to comment.