MCPcopy Create free account
hub / github.com/Illumina/paragraph / asFloat

Method asFloat

external/jsoncpp/jsoncpp.cpp:3328–3349  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3326}
3327
3328float Value::asFloat() const {
3329 switch (type_) {
3330 case intValue:
3331 return static_cast<float>(value_.int_);
3332 case uintValue:
3333#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
3334 return static_cast<float>(value_.uint_);
3335#else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
3336 // This can fail (silently?) if the value is bigger than MAX_FLOAT.
3337 return static_cast<float>(integerToDouble(value_.uint_));
3338#endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
3339 case realValue:
3340 return static_cast<float>(value_.real_);
3341 case nullValue:
3342 return 0.0;
3343 case booleanValue:
3344 return value_.bool_ ? 1.0f : 0.0f;
3345 default:
3346 break;
3347 }
3348 JSON_FAIL_MESSAGE("Value is not convertible to float.");
3349}
3350
3351bool Value::asBool() const {
3352 switch (type_) {

Callers

nothing calls this directly

Calls 1

integerToDoubleFunction · 0.85

Tested by

no test coverage detected