Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Property Grid
  New Posts New Posts RSS Feed - CXTPPropertyGridItemDouble::StringToDouble() fails
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CXTPPropertyGridItemDouble::StringToDouble() fails

 Post Reply Post Reply
Author
Message
fleg View Drop Down
Groupie
Groupie


Joined: 11 July 2012
Status: Offline
Points: 46
Post Options Post Options   Thanks (0) Thanks(0)   Quote fleg Quote  Post ReplyReply Direct Link To This Post Topic: CXTPPropertyGridItemDouble::StringToDouble() fails
    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?


Thanks,
Back to Top
agontarenko View Drop Down
Admin Group
Admin Group


Joined: 25 March 2016
Status: Offline
Points: 299
Post Options Post Options   Thanks (0) Thanks(0)   Quote agontarenko Quote  Post ReplyReply Direct Link To This Post Posted: 21 November 2024 at 4:17am
Hello,

I've increased buffer size to 32.

Regards,
Artem Gontarenko 
Back to Top
fleg View Drop Down
Groupie
Groupie


Joined: 11 July 2012
Status: Offline
Points: 46
Post Options Post Options   Thanks (0) Thanks(0)   Quote fleg Quote  Post ReplyReply Direct Link To This Post Posted: 22 November 2024 at 3:30am
Thanks!
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.188 seconds.