MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / asFloat

Method asFloat

Source/JSON/jsoncpp.cpp:2921–2941  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2919}
2920
2921float Value::asFloat() const {
2922 switch (type_) {
2923 case intValue:
2924 return static_cast<float>(value_.int_);
2925 case uintValue:
2926#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
2927 return static_cast<float>(value_.uint_);
2928#else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
2929 return integerToDouble(value_.uint_);
2930#endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
2931 case realValue:
2932 return static_cast<float>(value_.real_);
2933 case nullValue:
2934 return 0.0;
2935 case booleanValue:
2936 return value_.bool_ ? 1.0f : 0.0f;
2937 default:
2938 break;
2939 }
2940 JSON_FAIL_MESSAGE("Value is not convertible to float.");
2941}
2942
2943bool Value::asBool() const {
2944 switch (type_) {

Callers

nothing calls this directly

Calls 1

integerToDoubleFunction · 0.70

Tested by

no test coverage detected