-
Notifications
You must be signed in to change notification settings - Fork 988
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
add flbit-field
#882
add flbit-field
#882
Conversation
This is a candidate procedure for adding to a revision of R6RS. I suggest aligning it to the semantics and naming conventions set in R6RS. The procedures in R6RS dealing with IEEE representations are described in section 2.8 of the standard libraries. As the This suggests If |
@mnieper — Thanks for your comments. I don't think this operation is like the functions in 2.8 of the R6RS library, which operate on bytevectors. I don't immediately see a point to new operations on bytevectors, because it's already straightforward (using integer operations) to inspect bits of a floating point number as encoded in a bytevector. Your point about different IEEE formats is well taken in the context a standard, and I agree that |
Thank you for your response.
I didn't mean to add new bytevector operations; as you write, there is no point in doing so as there is already a straightforward solution. I referred to bytevectors to have a template for naming conventions and semantics (single/double, endianess, domain of argument).
The R6RS standard way to achieve what If it is useful for external code, a portable feature would even be better. The root problem is, of course, that one does not simply want to cast a flonum into an exact integer (to do bitwise arithmetic with that one) because 64-bits are typically more than the fixnum range (and thus would produce an allocation again) so one needs operations acting directly on flonums/inexact reals. In any case, the name PS How is the endianness handled in your operation? |
Like |
Ah, that was my fallacy. It is up to the |
By coincidence, I was looking for something like this last week while I was contemplating the WASM generic numeric operation I used an intermediate bytevector (from Racket), but I noticed that Chez Scheme provides Lines 319 to 322 in 95ee804
Lines 1284 to 1321 in 95ee804
|
The
flbit-field
operation is analogous tobitwise-bit-field
, but it extracts bits from a flonum.This operation seems useful to the Herbie developers, particularly at a use site where the flonum argument can be unboxed and the result is a fixnum, so that it can work without allocating.