CXTPPropertyGridItemDouble::StringToDouble() fails |
Post Reply |
Author | |
fleg
Groupie Joined: 11 July 2012 Status: Offline Points: 46 |
Post Options
Thanks(0)
Posted: 06 November 2024 at 11:33am |
Hi, I probably found a failure in CXTPPropertyGridItemDouble::StringToDouble() method. With some value where the string is > 20 char, the value we get is incorrect. Example: with "1.3856932626629e-04" no problem the item shows with precision I asked "-1.3857 E-4" ; but same as negative "-1.3856932626629E-04" (21 chars) get truncated to 20 chars, so "-1.3856932626629E-0" get converted to "-1.3857" losing the exponent. Looking at the code (version 24.0.0), this buffer of 20 chars looks suspicious. char astring[20]; WideCharToMultiByte(CP_ACP, 0, strValue, -1, astring, 20, NULL, NULL); return (double)atof(astring); from definition of limit of double that goes from -DBL_MIN to DBL_MAX DBL_MAX 1.7976931348623158e+308 -DBL_MIN -2.2250738585072014e-308 buffer should be at least 25 chars. you can reproduce the problem with sample app PropertyGrid.PropertyGrid.exe Can you consider a fix for next release? Also, as mentioned here https://forum.codejock.com/cxtppropertygriditemdoublestringtodouble_topic12540_post42376.html?KW=StringTodouble#42376 It could be good to have this method virtual. Thanks,
|
|
agontarenko
Admin Group Joined: 25 March 2016 Status: Offline Points: 291 |
Post Options
Thanks(0)
|
Hello,
I've increased buffer size to 32. Regards, Artem Gontarenko |
|
fleg
Groupie Joined: 11 July 2012 Status: Offline Points: 46 |
Post Options
Thanks(0)
|
Thanks!
|
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |