FastLED 3.10.8
Loading...
Searching...
No Matches

◆ operator>>() [8/10]

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

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

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

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

+ Here is the call graph for this function: