MCPcopy Create free account
hub / github.com/ComodoSecurity/openedr / asFloat

Method asFloat

edrav2/eprj/jsoncpp/src/lib_json/json_value.cpp:844–865  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

842}
843
844float Value::asFloat() const {
845 switch (type_) {
846 case intValue:
847 return static_cast<float>(value_.int_);
848 case uintValue:
849#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
850 return static_cast<float>(value_.uint_);
851#else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
852 // This can fail (silently?) if the value is bigger than MAX_FLOAT.
853 return static_cast<float>(integerToDouble(value_.uint_));
854#endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
855 case realValue:
856 return static_cast<float>(value_.real_);
857 case nullValue:
858 return 0.0;
859 case booleanValue:
860 return value_.bool_ ? 1.0f : 0.0f;
861 default:
862 break;
863 }
864 JSON_FAIL_MESSAGE("Value is not convertible to float.");
865}
866
867bool Value::asBool() const {
868 switch (type_) {

Callers 1

JSONTEST_FIXTUREFunction · 0.80

Calls 1

integerToDoubleFunction · 0.85

Tested by

no test coverage detected