diff --git a/tableschema/types/number.py b/tableschema/types/number.py index 5558daf..264fd0c 100644 --- a/tableschema/types/number.py +++ b/tableschema/types/number.py @@ -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 diff --git a/tests/types/test_number.py b/tests/types/test_number.py index abc17ca..cdabd3b 100644 --- a/tests/types/test_number.py +++ b/tests/types/test_number.py @@ -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), {}),