jk-jeon / dragonbox

Reference implementation of Dragonbox in C++
Apache License 2.0
588 stars 37 forks source link

Invalid template parameters when using toward_minus_infinity and toward_plus_infinity #26

Closed mrmixer closed 2 years ago

mrmixer commented 2 years ago

Trying to compile the following code, I get an error on line 2058, where the second parameter passed to divide_by_pow10 is significand_bits + kappa + 2 instead of carrier_uint or something similar. I also assume the 3rd parameter isn't the correct value.

#include "dragonbox.h"

int main( int argc, char** argv ) {

    float x = 1.234f;   
    auto v = jkj::dragonbox::to_decimal( x, jkj::dragonbox::policy::decimal_to_binary_rounding::toward_plus_infinity );
    return 0;
}

Compiling with MSVC: cl -nologo main.cpp -Fe:dragonbox.exe -Zi -Od -std:c++17

jk-jeon commented 2 years ago

Thanks a lot for catching this! Fixed in 02059bdee06beb9fea28a399e6463d1d1f8edbfa. Now v is set to be {12339999, -7}.