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

Function decimal_to_float16

cpp/fory/serialization/compatible_scalar.cc:940–953  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

938}
939
940bool decimal_to_float16(const Decimal &decimal, float16_t &out) {
941 std::string text;
942 if (!decimal_plain_string(decimal, text)) {
943 return false;
944 }
945 float parsed = std::strtof(text.c_str(), nullptr);
946 out = float16_t::from_float(parsed);
947 if (!float16_t::is_finite(out)) {
948 return false;
949 }
950 Decimal actual;
951 return decimal_from_float16(out, actual) &&
952 decimal_equal_value(decimal, actual);
953}
954
955bool decimal_to_bfloat16(const Decimal &decimal, bfloat16_t &out) {
956 std::string text;

Callers 1

scalar_to_float16Function · 0.70

Calls 3

decimal_plain_stringFunction · 0.85
decimal_from_float16Function · 0.85
decimal_equal_valueFunction · 0.85

Tested by

no test coverage detected