MCPcopy Create free account
hub / github.com/apache/fory / _float_text

Function _float_text

python/pyfory/converter.py:302–313  ·  view source on GitHub ↗
(value: float)

Source from the content-addressed store, hash-verified

300
301
302def _float_text(value: float) -> str:
303 if math.isnan(value) or math.isinf(value):
304 raise ValueError("non-finite float cannot convert to string")
305 if value == 0.0:
306 return "-0.0" if _is_negative_zero(value) else "0.0"
307 text = _plain_decimal_text(decimal.Decimal.from_float(value))
308 if "." not in text:
309 return f"{text}.0"
310 text = text.rstrip("0")
311 if text.endswith("."):
312 text += "0"
313 return text
314
315
316def _string_value(value) -> str:

Callers 1

_string_valueFunction · 0.85

Calls 3

_is_negative_zeroFunction · 0.85
_plain_decimal_textFunction · 0.85
from_floatMethod · 0.45

Tested by

no test coverage detected