FastLED 3.9.15
Loading...
Searching...
No Matches

◆ operator>>() [8/10]

istream_real & fl::istream_real::operator>> ( float & f)

Definition at line 302 of file istream.cpp.hpp.

302 {
303 string token;
304 if (readToken(token)) {
305 // Use the existing toFloat() method
306 f = token.toFloat();
307 // Check if parsing was successful by checking for valid float
308 // toFloat() returns 0.0f for invalid input, but we need to distinguish
309 // between actual 0.0f and parse failure
310 if (fl::almost_equal(f, 0.0f) && token != "0" && token != "0.0" && token != "0." && token.find("0") != 0) {
311 mFailed = true;
312 }
313 } else {
314 mFailed = true;
315 }
316 return *this;
317}
bool readToken(string &token)
constexpr bool almost_equal(T a, T b, U tolerance) FL_NOEXCEPT
Definition math.h:90

References istream_real(), fl::almost_equal(), fl::basic_string::find(), mFailed, readToken(), and fl::basic_string::toFloat().

+ Here is the call graph for this function: