MCPcopy Create free account
hub / github.com/Kitware/CMake / asFloat

Method asFloat

Utilities/cmjsoncpp/src/lib_json/json_value.cpp:781–802  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

779}
780
781float Value::asFloat() const {
782 switch (type()) {
783 case intValue:
784 return static_cast<float>(value_.int_);
785 case uintValue:
786#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
787 return static_cast<float>(value_.uint_);
788#else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
789 // This can fail (silently?) if the value is bigger than MAX_FLOAT.
790 return static_cast<float>(integerToDouble(value_.uint_));
791#endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
792 case realValue:
793 return static_cast<float>(value_.real_);
794 case nullValue:
795 return 0.0;
796 case booleanValue:
797 return value_.bool_ ? 1.0F : 0.0F;
798 default:
799 break;
800 }
801 JSON_FAIL_MESSAGE("Value is not convertible to float.");
802}
803
804bool Value::asBool() const {
805 switch (type()) {

Callers

nothing calls this directly

Calls 2

integerToDoubleFunction · 0.85
typeClass · 0.50

Tested by

no test coverage detected