MCPcopy Create free account
hub / github.com/Samsung/UTopia / asFloat

Method asFloat

external/jsoncpp/jsoncpp.cpp:3188–3209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3186}
3187
3188float Value::asFloat() const {
3189 switch (type()) {
3190 case intValue:
3191 return static_cast<float>(value_.int_);
3192 case uintValue:
3193#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
3194 return static_cast<float>(value_.uint_);
3195#else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
3196 // This can fail (silently?) if the value is bigger than MAX_FLOAT.
3197 return static_cast<float>(integerToDouble(value_.uint_));
3198#endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
3199 case realValue:
3200 return static_cast<float>(value_.real_);
3201 case nullValue:
3202 return 0.0;
3203 case booleanValue:
3204 return value_.bool_ ? 1.0f : 0.0f;
3205 default:
3206 break;
3207 }
3208 JSON_FAIL_MESSAGE("Value is not convertible to float.");
3209}
3210
3211bool Value::asBool() const {
3212 switch (type()) {

Callers

nothing calls this directly

Calls 1

integerToDoubleFunction · 0.85

Tested by

no test coverage detected