MCPcopy Create free account
hub / github.com/THUDM/AgentTuning / asFloat

Method asFloat

AgentBench.old/src/tasks/card_game/logic/src/jsoncpp/jsoncpp.cpp:3270–3291  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3268}
3269
3270float Value::asFloat() const {
3271 switch (type_) {
3272 case intValue:
3273 return static_cast<float>(value_.int_);
3274 case uintValue:
3275#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
3276 return static_cast<float>(value_.uint_);
3277#else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
3278 // This can fail (silently?) if the value is bigger than MAX_FLOAT.
3279 return static_cast<float>(integerToDouble(value_.uint_));
3280#endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
3281 case realValue:
3282 return static_cast<float>(value_.real_);
3283 case nullValue:
3284 return 0.0;
3285 case booleanValue:
3286 return value_.bool_ ? 1.0f : 0.0f;
3287 default:
3288 break;
3289 }
3290 JSON_FAIL_MESSAGE("Value is not convertible to float.");
3291}
3292
3293bool Value::asBool() const {
3294 switch (type_) {

Callers

nothing calls this directly

Calls 1

integerToDoubleFunction · 0.70

Tested by

no test coverage detected