MCPcopy Create free account
hub / github.com/PlayFab/gsdk / asFloat

Method asFloat

cpp/cppsdk/jsoncpp.cpp:3282–3303  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3280}
3281
3282float Value::asFloat() const {
3283 switch (type_) {
3284 case intValue:
3285 return static_cast<float>(value_.int_);
3286 case uintValue:
3287#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
3288 return static_cast<float>(value_.uint_);
3289#else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
3290 // This can fail (silently?) if the value is bigger than MAX_FLOAT.
3291 return static_cast<float>(integerToDouble(value_.uint_));
3292#endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
3293 case realValue:
3294 return static_cast<float>(value_.real_);
3295 case nullValue:
3296 return 0.0;
3297 case booleanValue:
3298 return value_.bool_ ? 1.0f : 0.0f;
3299 default:
3300 break;
3301 }
3302 JSON_FAIL_MESSAGE("Value is not convertible to float.");
3303}
3304
3305bool Value::asBool() const {
3306 switch (type_) {

Callers 1

FromJsonUtilPFunction · 0.80

Calls 1

integerToDoubleFunction · 0.85

Tested by

no test coverage detected