FastLED 3.10.6
Loading...
Searching...
No Matches

◆ operator>>() [8/10]

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

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

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