Hello Henri, thank you very much for your input.
Am 17.08.2015 um 12:42 schrieb Henri Verbeet:
If you're careful about using values that are exactly representable you can just use a simple compare, yeah. Arguably the more interesting tests would be values that aren't exactly representable with different FPU precision and rounding modes though.
As an aside, other potentially interesting things to test are the decimal separator depending on locale, different number digits depending on locale (e.g. "۰٫۲۵"), C99 hexadecimal floats, and floating point specials like e.g. 1.#inf/INF/INFINITY.
The tested values up to now were simple ones because the real implementaion is inherited from msvcrt.dll and the more detailed tests are probably there.
I just wanted to test how it behaves when a value fitting into a double is now put into a float. (As far as I can see is msvcr120 is the first version were this float version strtoX is available, therefore I did put the tests there).
For the different number digits - this would be more subject to wcstof and _wcstof_l ?
However, it took some time to find the meaning of "۰٫۲۵" ... I did some tests and only after changing formats in regional settings to Persian, on an otherwise german Windows, wcstof did correctly interpret "٠.٢۵" (ARABIC-INDIC DIGITs with an regular ','). "۰.۲۵" (EXTENDED ARABIC-INDIC DIGITs) did not work.
I will try to expand my tests with the other cases you mentioned and send a new version.
Kind regards, Bernhard
WCHAR floatl[] = {'0', ',', '2', '5', 0}; WCHAR floatm[] = {0x0660, 0x066b, 0x0662, 0x0665, 0}; /* L"٠٫٢۵" ARABIC-INDIC DIGIT */ WCHAR floatn[] = {0x06f0, 0x066b, 0x06f2, 0x06f5, 0}; /* L"۰٫۲۵" EXTENDED ARABIC-INDIC DIGIT*/ WCHAR floatq[] = {0x0660, '.', 0x0662, 0x0665, 0}; /* L"٠.٢۵" ARABIC-INDIC DIGIT */