Skip to content

Commit

Permalink
Add support for "1e6" as scientific notation (roo-rb#433)
Browse files Browse the repository at this point in the history
  • Loading branch information
amichal authored and aravindm committed Jun 18, 2019
1 parent 4a54621 commit 1c2c69e
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 @@ -24,7 +24,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 1c2c69e

Please sign in to comment.