Skip to content

Commit

Permalink
Merge 7aed40c into 19a9de0
Browse files Browse the repository at this point in the history
  • Loading branch information
roll committed Jun 28, 2019
2 parents 19a9de0 + 7aed40c commit 24522f6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tableschema/types/number.py
Expand Up @@ -26,6 +26,8 @@ def cast_number(format, value, **options):
elif not isinstance(value, six.integer_types + (float,)):
return ERROR
try:
if isinstance(value, float):
value = str(value)
value = Decimal(value)
except Exception:
return ERROR
Expand Down
1 change: 1 addition & 0 deletions tests/types/test_number.py
Expand Up @@ -20,6 +20,7 @@
('default', '1', Decimal(1), {}),
('default', '10.00', Decimal(10), {}),
('default', '10.50', Decimal(10.5), {}),
('default', 24.122667, Decimal('24.122667'), {}),
('default', '100%', Decimal(100), {'bareNumber': False}),
('default', '1000‰', Decimal(1000), {'bareNumber': False}),
('default', '-1000', Decimal(-1000), {}),
Expand Down

0 comments on commit 24522f6

Please sign in to comment.