VirtualBox

Ignore:
Timestamp:
Aug 11, 2022 11:49:45 PM (2 years ago)
Author:
vboxsync
Message:

IPRT: Added RTStrToFloat, RTStrToDouble and RTStrToLongDouble. Still some rought edges; only tested on Windows. bugref:10261

Location:
trunk/src/VBox/Runtime/common/string
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/string/strtonum.cpp

    r96127 r96152  
    4141*********************************************************************************************************************************/
    4242/** 8-bit char -> digit.
    43  * Non-digits have values 255 (most), 254 (zero), 253 (colon) and 252 (space).
    44  */
    45 static const unsigned char g_auchDigits[256] =
     43 * Non-digits have values 255 (most), 254 (zero), 253 (colon), 252 (space), 251 (dot).
     44 *
     45 * @note Also used by strtofloat.cpp
     46 */
     47extern const unsigned char g_auchDigits[256] =
    4648{
    4749    254,255,255,255,255,255,255,255,255,252,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
    48     252,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9,253,255,255,255,255,255,
     50    252,255,255,255,255,255,255,255,255,255,255,255,255,255,251,255,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9,253,255,255,255,255,255,
    4951    255, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,255,255,255,255,255,
    5052    255, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,255,255,255,255,255,
     
    5456    255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
    5557};
     58
     59#define DIGITS_ZERO_TERM 254
     60#define DIGITS_COLON     253
     61#define DIGITS_SPACE     252
     62#define DIGITS_DOT       251
    5663
    5764/** Approximated overflow shift checks. */
     
    8491        else if (i == ' ' || i == '\t')
    8592            ch = 252;
     93        else if (i == '.')
     94            ch = 251;
    8695        if (i == 0)
    8796            printf("\n    %3d", ch);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette