Fix and document wxDecToHex()

1. Integer instead of floating point arithmetic should be used in calculations.
2. Because this function always returns 2 hexadecimal characters, its parameter type should be changed from 'int' to 'unsigned char' to avoid misunderstandings and prevent misuses.

Closes #12612.
This commit is contained in:
Artur Wieczorek
2017-02-23 20:00:13 +01:00
parent bfa2b2896b
commit 2934f77660
3 changed files with 67 additions and 17 deletions

View File

@@ -309,9 +309,9 @@ inline int wxHexToDec(const char* buf)
// Convert decimal integer to 2-character hex string
WXDLLIMPEXP_BASE void wxDecToHex(int dec, wxChar *buf);
WXDLLIMPEXP_BASE void wxDecToHex(int dec, char* ch1, char* ch2);
WXDLLIMPEXP_BASE wxString wxDecToHex(int dec);
WXDLLIMPEXP_BASE void wxDecToHex(unsigned char dec, wxChar *buf);
WXDLLIMPEXP_BASE void wxDecToHex(unsigned char dec, char* ch1, char* ch2);
WXDLLIMPEXP_BASE wxString wxDecToHex(unsigned char dec);
// ----------------------------------------------------------------------------
// Process management