-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect representation with Schubfach? #13
Comments
Java, C++ (std::to_chars), and JavaScript all have slightly different formatting specifications. The Java implementation requires to print two significant digits for the minimum You can customize the current formatting procedure slightly by tweaking these constants Drachennest/src/schubfach_64.cc Lines 1171 to 1172 in e6714a3
IIRC JavaScript uses These constants do not affect the correctness of the algorithm. You can choose (almost) any pair of values here. Or you could even write your own formatting procedure if you like: The core algorithm gives you a number of the form |
I know about these values, but that's in In the Java implementation, The C++ version does the rounding but with I don't know the algorithm enough to see why it's different, but I can probably trace where it starts to diverge. I'm not sure whether it's important or not. |
I doubt that it changes anything about the conclusion for your project though, it's only a small difference of output for the smallest value. 😉 |
Actually, I think it's because of this particular mode in the Java implementation, so maybe not an issue, or something that can be added if someone requires the extra precision: In DoubleDecimal.java, // subnormal value
return t < C_TINY
? toDecimal(Q_MIN, 10 * t, -1)
: toDecimal(Q_MIN, t, 0); with |
With a double-precision value corresponding to the minimum value (hex representation
0x0000000000000001
),4.9E-324
"5e-324
"The expected string is coming from the Java implementation from the algorithm's author, Raffaello Giulietti.
I haven't done a more thorough test to see if there were other discrepancies. Most of the results are definitely fine but finding different values, and seeing the algorithm has been adapted, is not reassuring. Perhaps were there small adaptations in the original algorithm? There are several versions of the article.
Quick and dirty test file (requires schubfach_64.cpp and schubfach_64.h)
The text was updated successfully, but these errors were encountered: