On 4/21/22 20:11, Gabriel Ivăncescu wrote:
Hi Jacek,
On 21/04/2022 15:45, Jacek Caban wrote:
Hi Gabriel,
On 4/20/22 18:56, Gabriel Ivăncescu wrote:
Signed-off-by: Gabriel Ivăncescugabrielopcode@gmail.com
I kept the fraction removal since I couldn't think of a better way for now. However, the other improvements have been done.
Could we just modify the existing toString() code to optionally take into account localized separators and required customizations? It seems to me that avoiding exponential form is simply a matter of using a larger buffer for localized string.
Do you mean to localize the entire number ourselves in toString? Or just the sprintf part? (so it can be passed to GetNumberFormatW)
I don't know if localizing the number in toString without using an API like GetNumberFormatW is a good idea—I certainly don't know the required customizations for each locale, having to implement them sounds like a lot of duplication, and is it possible they could even change in the future?
You seem to assume that GetNumberFormatW does what we need, but the differences that you found with native suggests otherwise. If something theoretically changes about it in the future, it not clear if that it would be desirable for jscript behaviour to change.
Anyway, using toString() may indeed be not really be convenient. There is also NUMBERFMTW parameter to GetNumberFormatW, which has NumDigits that does what you need. The unfortunate thing is that preparing NUMBERFORMATW is not really convenient. It may be worth to try to use that. If it doesn't work out, I guess we may need to use something like your patch after all.
Thanks,
Jacek