MCPcopy Create free account
hub / github.com/CytopiaTeam/Cytopia / parseFloat

Function parseFloat

external/as_add_on/scriptstdstring/scriptstdstring.cpp:670–695  ·  view source on GitHub ↗

AngelScript signature: double parseFloat(const string &in val, uint &out byteCount = 0)

Source from the content-addressed store, hash-verified

668// AngelScript signature:
669// double parseFloat(const string &in val, uint &out byteCount = 0)
670double parseFloat(const string &val, asUINT *byteCount)
671{
672 char *end;
673
674 // WinCE doesn't have setlocale. Some quick testing on my current platform
675 // still manages to parse the numbers such as "3.14" even if the decimal for the
676 // locale is ",".
677#if !defined(_WIN32_WCE) && !defined(ANDROID) && !defined(__psp2__)
678 // Set the locale to C so that we are guaranteed to parse the float value correctly
679 char *tmp = setlocale(LC_NUMERIC, 0);
680 string orig = tmp ? tmp : "C";
681 setlocale(LC_NUMERIC, "C");
682#endif
683
684 double res = strtod(val.c_str(), &end);
685
686#if !defined(_WIN32_WCE) && !defined(ANDROID) && !defined(__psp2__)
687 // Restore the locale
688 setlocale(LC_NUMERIC, orig.c_str());
689#endif
690
691 if( byteCount )
692 *byteCount = asUINT(size_t(end - val.c_str()));
693
694 return res;
695}
696
697// This function returns a string containing the substring of the input string
698// determined by the starting index and count of characters.

Callers 1

parseFloat_GenericFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected