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

Method asFloat

runtime/3rdparty/jsoncpp/jsoncpp.cpp:3460–3483  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3458}
3459
3460float Value::asFloat() const
3461{
3462 switch (type())
3463 {
3464 case intValue:
3465 return static_cast<float>(value_.int_);
3466 case uintValue:
3467#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
3468 return static_cast<float>(value_.uint_);
3469#else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
3470 // This can fail (silently?) if the value is bigger than MAX_FLOAT.
3471 return static_cast<float>(integerToDouble(value_.uint_));
3472#endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
3473 case realValue:
3474 return static_cast<float>(value_.real_);
3475 case nullValue:
3476 return 0.0;
3477 case booleanValue:
3478 return value_.bool_ ? 1.0F : 0.0F;
3479 default:
3480 break;
3481 }
3482 JSON_FAIL_MESSAGE("Value is not convertible to float.");
3483}
3484
3485bool Value::asBool() const
3486{

Callers 2

initMethod · 0.45
readFunction · 0.45

Calls 2

integerToDoubleFunction · 0.85
typeFunction · 0.50

Tested by

no test coverage detected