VirtualBox

Changeset 96156 in vbox


Ignore:
Timestamp:
Aug 12, 2022 12:01:44 AM (2 years ago)
Author:
vboxsync
Message:

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

Location:
trunk/src/VBox/Runtime/common/string
Files:
2 edited

Legend:

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

    r96153 r96156  
    140140    for (unsigned iBit = 0; iBit < 13; iBit++)
    141141    {
    142         RTAssertMsg2("    { %#018RX64, %#018RX64 }, %c* 1e%u (%RU64) *%c\n", Power10.v[0], Power10.v[1],
     142        RTAssertMsg2("    { UINT64_C(%#018RX64), UINT64_C(%#018RX64) }, %c* 1e%u (%RU64) *%c\n", Power10.v[0], Power10.v[1],
    143143                     '/', RT_BIT_32(iBit), f128M_to_ui64(&Power10, softfloat_round_near_even, false, &SoftState), '/');
    144144        f128M_mul(&Power10, &Power10, &Power10, &SoftState);
     
    147147static const float128_t g_ar128Power10[] =
    148148{
    149     { 0x0000000000000000, 0x4002400000000000 }, /* 1e1 (10) */
    150     { 0x0000000000000000, 0x4005900000000000 }, /* 1e2 (100) */
    151     { 0x0000000000000000, 0x400c388000000000 }, /* 1e4 (10000) */
    152     { 0x0000000000000000, 0x40197d7840000000 }, /* 1e8 (100000000) */
    153     { 0x0000000000000000, 0x40341c37937e0800 }, /* 1e16 (10000000000000000) */
    154     { 0x6b3be04000000000, 0x40693b8b5b5056e1 }, /* 1e32 (18446744073709551615) */
    155     { 0x4daa797ed6e38ed6, 0x40d384f03e93ff9f }, /* 1e64 (18446744073709551615) */
    156     { 0x19bf8cde66d86d61, 0x41a827748f9301d3 }, /* 1e128 (18446744073709551615) */
    157     { 0xbd1bbb77203731fb, 0x435154fdd7f73bf3 }, /* 1e256 (18446744073709551615) */
    158     { 0x238d98cab8a97899, 0x46a3c633415d4c1d }, /* 1e512 (18446744073709551615) */
    159     { 0x182eca1a7a51e308, 0x4d4892eceb0d02ea }, /* 1e1024 (18446744073709551615) */
    160     { 0xbbc94e9a519c651e, 0x5a923d1676bb8a7a }, /* 1e2048 (18446744073709551615) */
    161     { 0x2f3592982a7f005a, 0x752588c0a4051441 }, /* 1e4096 (18446744073709551615) */
     149    { UINT64_C(0x0000000000000000), UINT64_C(0x4002400000000000) }, /* 1e1 (10) */
     150    { UINT64_C(0x0000000000000000), UINT64_C(0x4005900000000000) }, /* 1e2 (100) */
     151    { UINT64_C(0x0000000000000000), UINT64_C(0x400c388000000000) }, /* 1e4 (10000) */
     152    { UINT64_C(0x0000000000000000), UINT64_C(0x40197d7840000000) }, /* 1e8 (100000000) */
     153    { UINT64_C(0x0000000000000000), UINT64_C(0x40341c37937e0800) }, /* 1e16 (10000000000000000) */
     154    { UINT64_C(0x6b3be04000000000), UINT64_C(0x40693b8b5b5056e1) }, /* 1e32 (18446744073709551615) */
     155    { UINT64_C(0x4daa797ed6e38ed6), UINT64_C(0x40d384f03e93ff9f) }, /* 1e64 (18446744073709551615) */
     156    { UINT64_C(0x19bf8cde66d86d61), UINT64_C(0x41a827748f9301d3) }, /* 1e128 (18446744073709551615) */
     157    { UINT64_C(0xbd1bbb77203731fb), UINT64_C(0x435154fdd7f73bf3) }, /* 1e256 (18446744073709551615) */
     158    { UINT64_C(0x238d98cab8a97899), UINT64_C(0x46a3c633415d4c1d) }, /* 1e512 (18446744073709551615) */
     159    { UINT64_C(0x182eca1a7a51e308), UINT64_C(0x4d4892eceb0d02ea) }, /* 1e1024 (18446744073709551615) */
     160    { UINT64_C(0xbbc94e9a519c651e), UINT64_C(0x5a923d1676bb8a7a) }, /* 1e2048 (18446744073709551615) */
     161    { UINT64_C(0x2f3592982a7f005a), UINT64_C(0x752588c0a4051441) }, /* 1e4096 (18446744073709551615) */
    162162    /* INF */
    163163};
     
    175175    for (unsigned cTimes = 0; cTimes < 32; cTimes++)
    176176    {
    177         RTAssertMsg2("        { %#018RX64, %#018RX64 }, %c* 1e%u (%RU64) *%c\n", Power10.v[0], Power10.v[1],
     177        RTAssertMsg2("        { UINT64_C(%#018RX64), UINT64_C(%#018RX64) }, %c* 1e%u (%RU64) *%c\n", Power10.v[0], Power10.v[1],
    178178                     '/', cTimes, f128M_to_ui64(&Power10, softfloat_round_near_even, false, &SoftState), '/');
    179179        f128M_mul(&Power10, &Num10, &Power10, &SoftState);
     
    182182static const float128_t g_ar128Power10Initial[] =
    183183{
    184     { 0x0000000000000000, 0x3fff000000000000 }, /* 1e0 (1) */
    185     { 0x0000000000000000, 0x4002400000000000 }, /* 1e1 (10) */
    186     { 0x0000000000000000, 0x4005900000000000 }, /* 1e2 (100) */
    187     { 0x0000000000000000, 0x4008f40000000000 }, /* 1e3 (1000) */
    188     { 0x0000000000000000, 0x400c388000000000 }, /* 1e4 (10000) */
    189     { 0x0000000000000000, 0x400f86a000000000 }, /* 1e5 (100000) */
    190     { 0x0000000000000000, 0x4012e84800000000 }, /* 1e6 (1000000) */
    191     { 0x0000000000000000, 0x4016312d00000000 }, /* 1e7 (10000000) */
    192     { 0x0000000000000000, 0x40197d7840000000 }, /* 1e8 (100000000) */
    193     { 0x0000000000000000, 0x401cdcd650000000 }, /* 1e9 (1000000000) */
    194     { 0x0000000000000000, 0x40202a05f2000000 }, /* 1e10 (10000000000) */
    195     { 0x0000000000000000, 0x402374876e800000 }, /* 1e11 (100000000000) */
    196     { 0x0000000000000000, 0x4026d1a94a200000 }, /* 1e12 (1000000000000) */
    197     { 0x0000000000000000, 0x402a2309ce540000 }, /* 1e13 (10000000000000) */
    198     { 0x0000000000000000, 0x402d6bcc41e90000 }, /* 1e14 (100000000000000) */
    199     { 0x0000000000000000, 0x4030c6bf52634000 }, /* 1e15 (1000000000000000) */
    200     { 0x0000000000000000, 0x40341c37937e0800 }, /* 1e16 (10000000000000000) */
    201     { 0x0000000000000000, 0x40376345785d8a00 }, /* 1e17 (100000000000000000) */
    202     { 0x0000000000000000, 0x403abc16d674ec80 }, /* 1e18 (1000000000000000000) */
    203     { 0x0000000000000000, 0x403e158e460913d0 }, /* 1e19 (10000000000000000000) */
    204     { 0x0000000000000000, 0x40415af1d78b58c4 }, /* 1e20 (18446744073709551615) */
    205     { 0x0000000000000000, 0x4044b1ae4d6e2ef5 }, /* 1e21 (18446744073709551615) */
    206     { 0x2000000000000000, 0x40480f0cf064dd59 }, /* 1e22 (18446744073709551615) */
    207     { 0x6800000000000000, 0x404b52d02c7e14af }, /* 1e23 (18446744073709551615) */
    208     { 0x4200000000000000, 0x404ea784379d99db }, /* 1e24 (18446744073709551615) */
    209     { 0x0940000000000000, 0x405208b2a2c28029 }, /* 1e25 (18446744073709551615) */
    210     { 0x4b90000000000000, 0x40554adf4b732033 }, /* 1e26 (18446744073709551615) */
    211     { 0x1e74000000000000, 0x40589d971e4fe840 }, /* 1e27 (18446744073709551615) */
    212     { 0x1308800000000000, 0x405c027e72f1f128 }, /* 1e28 (18446744073709551615) */
    213     { 0x17caa00000000000, 0x405f431e0fae6d72 }, /* 1e29 (18446744073709551615) */
    214     { 0x9dbd480000000000, 0x406293e5939a08ce }, /* 1e30 (18446744073709551615) */
    215     { 0x452c9a0000000000, 0x4065f8def8808b02 }, /* 1e31 (18446744073709551615) */
     184    { UINT64_C(0x0000000000000000), UINT64_C(0x3fff000000000000) }, /* 1e0 (1) */
     185    { UINT64_C(0x0000000000000000), UINT64_C(0x4002400000000000) }, /* 1e1 (10) */
     186    { UINT64_C(0x0000000000000000), UINT64_C(0x4005900000000000) }, /* 1e2 (100) */
     187    { UINT64_C(0x0000000000000000), UINT64_C(0x4008f40000000000) }, /* 1e3 (1000) */
     188    { UINT64_C(0x0000000000000000), UINT64_C(0x400c388000000000) }, /* 1e4 (10000) */
     189    { UINT64_C(0x0000000000000000), UINT64_C(0x400f86a000000000) }, /* 1e5 (100000) */
     190    { UINT64_C(0x0000000000000000), UINT64_C(0x4012e84800000000) }, /* 1e6 (1000000) */
     191    { UINT64_C(0x0000000000000000), UINT64_C(0x4016312d00000000) }, /* 1e7 (10000000) */
     192    { UINT64_C(0x0000000000000000), UINT64_C(0x40197d7840000000) }, /* 1e8 (100000000) */
     193    { UINT64_C(0x0000000000000000), UINT64_C(0x401cdcd650000000) }, /* 1e9 (1000000000) */
     194    { UINT64_C(0x0000000000000000), UINT64_C(0x40202a05f2000000) }, /* 1e10 (10000000000) */
     195    { UINT64_C(0x0000000000000000), UINT64_C(0x402374876e800000) }, /* 1e11 (100000000000) */
     196    { UINT64_C(0x0000000000000000), UINT64_C(0x4026d1a94a200000) }, /* 1e12 (1000000000000) */
     197    { UINT64_C(0x0000000000000000), UINT64_C(0x402a2309ce540000) }, /* 1e13 (10000000000000) */
     198    { UINT64_C(0x0000000000000000), UINT64_C(0x402d6bcc41e90000) }, /* 1e14 (100000000000000) */
     199    { UINT64_C(0x0000000000000000), UINT64_C(0x4030c6bf52634000) }, /* 1e15 (1000000000000000) */
     200    { UINT64_C(0x0000000000000000), UINT64_C(0x40341c37937e0800) }, /* 1e16 (10000000000000000) */
     201    { UINT64_C(0x0000000000000000), UINT64_C(0x40376345785d8a00) }, /* 1e17 (100000000000000000) */
     202    { UINT64_C(0x0000000000000000), UINT64_C(0x403abc16d674ec80) }, /* 1e18 (1000000000000000000) */
     203    { UINT64_C(0x0000000000000000), UINT64_C(0x403e158e460913d0) }, /* 1e19 (10000000000000000000) */
     204    { UINT64_C(0x0000000000000000), UINT64_C(0x40415af1d78b58c4) }, /* 1e20 (18446744073709551615) */
     205    { UINT64_C(0x0000000000000000), UINT64_C(0x4044b1ae4d6e2ef5) }, /* 1e21 (18446744073709551615) */
     206    { UINT64_C(0x2000000000000000), UINT64_C(0x40480f0cf064dd59) }, /* 1e22 (18446744073709551615) */
     207    { UINT64_C(0x6800000000000000), UINT64_C(0x404b52d02c7e14af) }, /* 1e23 (18446744073709551615) */
     208    { UINT64_C(0x4200000000000000), UINT64_C(0x404ea784379d99db) }, /* 1e24 (18446744073709551615) */
     209    { UINT64_C(0x0940000000000000), UINT64_C(0x405208b2a2c28029) }, /* 1e25 (18446744073709551615) */
     210    { UINT64_C(0x4b90000000000000), UINT64_C(0x40554adf4b732033) }, /* 1e26 (18446744073709551615) */
     211    { UINT64_C(0x1e74000000000000), UINT64_C(0x40589d971e4fe840) }, /* 1e27 (18446744073709551615) */
     212    { UINT64_C(0x1308800000000000), UINT64_C(0x405c027e72f1f128) }, /* 1e28 (18446744073709551615) */
     213    { UINT64_C(0x17caa00000000000), UINT64_C(0x405f431e0fae6d72) }, /* 1e29 (18446744073709551615) */
     214    { UINT64_C(0x9dbd480000000000), UINT64_C(0x406293e5939a08ce) }, /* 1e30 (18446744073709551615) */
     215    { UINT64_C(0x452c9a0000000000), UINT64_C(0x4065f8def8808b02) }, /* 1e31 (18446744073709551615) */
    216216};
    217217
  • trunk/src/VBox/Runtime/common/string/strtonum.cpp

    r96152 r96156  
    4040*   Global Variables                                                                                                             *
    4141*********************************************************************************************************************************/
     42extern const unsigned char g_auchDigits[256]; /* shared with strtofloat.cpp - add header? */
     43
    4244/** 8-bit char -> digit.
    4345 * Non-digits have values 255 (most), 254 (zero), 253 (colon), 252 (space), 251 (dot).
     
    4547 * @note Also used by strtofloat.cpp
    4648 */
    47 extern const unsigned char g_auchDigits[256] =
     49const unsigned char g_auchDigits[256] =
    4850{
    4951    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,
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