pip_services3_commons.convert.FloatConverter module
pip_services3_commons.convert.FloatConverter
Float conversion utilities
- copyright
Conceptual Vision Consulting LLC 2018-2019, see AUTHORS for more details.
- license
MIT, see LICENSE for more details.
-
class
pip_services3_commons.convert.FloatConverter.
FloatConverter
Bases:
object
Converts arbitrary values into float using extended conversion __rules: - Strings are converted to float values - DateTime: total number of milliseconds since unix epoсh - Boolean: 1 for true and 0 for false
Example: .. code-block:: python
value1 = FloatConverter.to_nullable_float(“ABC”) # Result: None value2 = FloatConverter.to_nullable_float(“123.456”) # Result: 123.456 value3 = FloatConverter.to_nullable_float(true) # Result: 1 value4 = FloatConverter.to_nullable_float(datetime.datetime.now()) # Result: current milliseconds
-
static
to_float
(value: Any) → float Converts args into float or returns 0 when conversion is not possible.
- Parameters
value – the args to convert.
- Returns
float args or 0 when conversion is not supported.
-
static