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

Function decimal_to_bfloat16

cpp/fory/serialization/compatible_scalar.cc:955–968  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

953}
954
955bool decimal_to_bfloat16(const Decimal &decimal, bfloat16_t &out) {
956 std::string text;
957 if (!decimal_plain_string(decimal, text)) {
958 return false;
959 }
960 float parsed = std::strtof(text.c_str(), nullptr);
961 out = bfloat16_t::from_float(parsed);
962 if (!bfloat16_t::is_finite(out)) {
963 return false;
964 }
965 Decimal actual;
966 return decimal_from_bfloat16(out, actual) &&
967 decimal_equal_value(decimal, actual);
968}
969
970bool decimal_to_float32(const Decimal &decimal, bool negative_zero,
971 float &out) {

Callers 1

scalar_to_bfloat16Function · 0.70

Calls 3

decimal_plain_stringFunction · 0.85
decimal_from_bfloat16Function · 0.85
decimal_equal_valueFunction · 0.85

Tested by

no test coverage detected