Skip to content
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

Make float::from_bits transmute #46012

Merged
merged 1 commit into from
Nov 24, 2017
Merged

Commits on Nov 23, 2017

  1. Make float::from_bits transmute (and update the documentation to refl…

    …ect this).
    
    The current implementation/documentation was made to avoid sNaN because of
    potential safety issues implied by old/bad LLVM documentation. These issues
    aren't real, so we can just make the implementation transmute (as permitted
    by the existing documentation of this method).
    
    Also the documentation didn't actually match the behaviour: it said we may
    change sNaNs, but in fact we canonicalized *all* NaNs.
    
    Also an example in the documentation was wrong: it said we *always* change
    sNaNs, when the documentation was explicitly written to indicate it was
    implementation-defined.
    
    This makes to_bits and from_bits perfectly roundtrip cross-platform, except
    for one caveat: although the 2008 edition of IEEE-754 specifies how to
    interpet the signaling bit, earlier editions didn't. This lead to some platforms
    picking the opposite interpretation, so all signaling NaNs on x86/ARM are quiet
    on MIPS, and vice-versa.
    
    NaN-boxing is a fairly important optimization, while we don't even guarantee
    that float operations properly preserve signalingness. As such, this seems like
    the more natural strategy to take (as opposed to trying to mangle the signaling
    bit on a per-platform basis).
    
    This implementation is also, of course, faster.
    Gankra committed Nov 23, 2017
    Configuration menu
    Copy the full SHA
    439576f View commit details
    Browse the repository at this point in the history