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

Function decimal_to_float32

cpp/fory/serialization/compatible_scalar.cc:970–986  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

968}
969
970bool decimal_to_float32(const Decimal &decimal, bool negative_zero,
971 float &out) {
972 std::string text;
973 if (!decimal_plain_string(decimal, text)) {
974 return false;
975 }
976 out = std::strtof(text.c_str(), nullptr);
977 if (negative_zero && decimal.is_zero()) {
978 out = -0.0f;
979 }
980 if (!std::isfinite(out)) {
981 return false;
982 }
983 Decimal actual;
984 return decimal_from_float32(out, actual) &&
985 decimal_equal_value(decimal, actual);
986}
987
988bool decimal_to_float64(const Decimal &decimal, bool negative_zero,
989 double &out) {

Callers 1

scalar_to_float32Function · 0.85

Calls 4

decimal_plain_stringFunction · 0.85
decimal_from_float32Function · 0.85
decimal_equal_valueFunction · 0.85
is_zeroMethod · 0.45

Tested by

no test coverage detected