-
Notifications
You must be signed in to change notification settings - Fork 102
Introduce hf32!
and hf64!
macros for hex float support
#351
Conversation
c3175ee
to
886e3fa
Compare
@quaternic since you have already looked at this algorithm some, would you mind reviewing it here? :) |
On a high level, I have two considerations: Firstly, I think the parsing code could be streamlined significantly. As one particular idea, Secondly, it should handle inputs that cannot be represented in the target type, alternatives:
Allowing for both might be ideal, but it's probably not needed for the purposes of this crate. The bug in |
Thanks for the feedback! I updated with your suggestion for handling excess precision, that could use a look. I am not quite sure what you have in mind re. returning (feel free to sketch it out on the playground if you had something in mind - I'm not tied to this implementation, it was just something I could get together quick) (I have no clue why this would be getting a SIGILL on ppc but I am sure it is unrelated - maybe something with how |
Right, yes, I meant refactoring it to separate parsing from the details of the target representation.
Alright, I can do that! |
Why, oh why, did I volunteer to write parsing code. (edit: As a In functionality, one concrete improvement is support for any integer parts as in |
d193a78
to
d088acc
Compare
Well, thanks for doing it!
That wasn't even a goal since C never produces those, above and beyond! I had to massage a few things but I basically picked up exactly what you had. I'll merge it in a bit unless anything else jumps out to you. |
Thanks for putting it together! Looks about right to me. |
Rust does not have any native way to parse hex floats, but they are heavily used in the C algorithms that we derive from. Introduce a const function that can parse these, as well as macros `hf32!` and `hf64!` that ensure the string literals get handled at compiler time. These are currently not used but making everything available now will ease future development. Co-authored-by: quaternic <[email protected]>
Rust does not have any native way to parse hex floats, but they are heavily used in the C algorithms that we derive from. Introduce a const function that can parse these, as well as macros
hf32!
andhf64!
that ensure the string literals get handled at compiler time.These are currently not used but making everything available now will ease future development.