MCPcopy Create free account
hub / github.com/Exiv2/exiv2 / parseFloat

Function parseFloat

src/types.cpp:568–588  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

566}
567
568float parseFloat(const std::string& s, bool& ok) {
569 auto ret = stringTo<float>(s, ok);
570 if (ok)
571 return ret;
572
573 auto [r, st] = stringTo<Rational>(s, ok);
574 if (ok) {
575 if (st == 0) {
576 ok = false;
577 return 0.0;
578 }
579 return static_cast<float>(r) / st;
580 }
581
582 bool b = stringTo<bool>(s, ok);
583 if (ok)
584 return b ? 1.0F : 0.0F;
585
586 // everything failed, return from stringTo<float> is probably the best fit
587 return ret;
588}
589
590Rational parseRational(const std::string& s, bool& ok) {
591 auto ret = stringTo<Rational>(s, ok);

Callers 2

mainFunction · 0.85
toFloatMethod · 0.85

Calls

no outgoing calls

Tested by 1

mainFunction · 0.68