-
Notifications
You must be signed in to change notification settings - Fork 47
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
Bit slice #2176
base: main
Are you sure you want to change the base?
Bit slice #2176
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Angelica-Schell! I left a few comments on the new bit manipulation implementation; let me know if you'd like me to clarify anything.
@@ -106,6 +116,7 @@ fn convert( | |||
convert_from: NumType, | |||
convert_to: NumType, | |||
exponent: i32, | |||
bits: bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you're listing all the arguments in the doc comment, you should probably add bits
. And incidentally, it looks like the descriptions of convert_{from,to}
are out of date, as they refer to "references" that were removed.
11110100 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason that this test is being overwritten instead of adding a new one? (Or, if these tests aren't meant to be part of a permanent test suite, then they probably shouldn't be committed.)
/// # Panics | ||
/// | ||
/// This function will panic if the input string cannot be parsed as a binary number. | ||
fn binary_to_fixed_bit_slice( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps I'm missing something, but I was under the impression that it was the fixed_to_binary
function where we were going to try a bit manipulation implementation? Having a second implementation of binary_to_fixed
would still work for testing your benchmarking setup, though.
data-conversion/src/main.rs
Outdated
let frac = fractional_part; | ||
for i in 0..shift_amount { | ||
if (frac & (1 << i)) != 0 { | ||
frac_part_value += 1.0 / (1 << (shift_amount - i)) as f64; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the following comment is misguided, since I was originally thinking about bit manipulation in the context of fixed_to_binary
. But I would sort of imagine that the goal for a bit manipulation version of binary_to_fixed
would be to assemble the floating-point bit representation directly from the fixed-point bit representation and the exponent, in order to avoid doing any expensive floating-point operations. I.e., we would try to avoid doing these floating-point additions and divisions here?
Adding binary to fixed using bit slicing instead of multiplication. Use the -b flag to use this version instead