You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I try to implement the dragon4 algorithm for another C++ project (https://github.com/Viatorus/emio/) and came across your well structured implementation.
I think I understand the most but the one which doesn't make total sense to me is the estimation of k and the fix up routine.
Maybe you could answer me my question. If not, I'm sorry to have bothered you. I already appreciate your great work!
The estimation function looks really clever, since it doesn't use any double arithmetic:
pub fn estimate_scaling_factor(mant: u64, exp: i16) -> i16 {
// 2^(nbits-1) < mant <= 2^nbits if mant > 0
let nbits = 64 - (mant - 1).leading_zeros() as i64;
// 1292913986 = floor(2^32 * log_10 2)
// therefore this always underestimates (or is exact), but not much.
(((nbits + exp as i64) * 1292913986) >> 32) as i16
}
Hi there,
I try to implement the dragon4 algorithm for another C++ project (https://github.com/Viatorus/emio/) and came across your well structured implementation.
I think I understand the most but the one which doesn't make total sense to me is the estimation of k and the fix up routine.
Maybe you could answer me my question. If not, I'm sorry to have bothered you. I already appreciate your great work!
I saw other estimations, which use double arithmetic:
https://github.com/google/double-conversion/blob/256ac809561b756645e73ab7127c2aaaeabaa427/double-conversion/bignum-dtoa.cc#L407-L413
https://github.com/eblot/newlib/blob/a1ee8f65e56ede59738f5d68a12f2cef0774d977/newlib/libc/stdlib/dtoa.c#L356
How would you compare your estimation against other? Where did your implementation idea came from?
rust-strconv/src/flt2dec/strategy/dragon.rs
Lines 247 to 254 in 7361c1c
Why must we depend on
buf.len()
(which is ~826). Couldn't we use the same check from format_shortest?rust-strconv/src/flt2dec/strategy/dragon.rs
Lines 123 to 129 in 7361c1c
Thank you very much in advance!
The text was updated successfully, but these errors were encountered: