ulfjack / ryu

Converts floating point numbers to decimal strings
Apache License 2.0
1.2k stars 100 forks source link

non 64 bit version of s2d asserts #167

Closed ejb77 closed 4 years ago

ejb77 commented 4 years ago

in the case of s2d("0.2316419", &d); s2d calls mulShift64(m=2316419, mul = 9774590264567735146, j= j=92), which calls shiftright128(lo=2525993831686973224, hi=242894, dist=28) ;

However in non 64 bit version of shiftright128, there is an assert(dist >32). Clearly with the value of 28, it asserts. // Avoid a 64-bit shift by taking advantage of the range of shift values. assert(dist >= 32); return (hi << (64 - dist)) | ((uint32_t)(lo >> 32) >> (dist - 32));

shiftright128 returns the wrong value.

ulfjack commented 4 years ago

Thanks, good catch!