Skip to content

possible issue with u64->f64 conversion in rand/float.rs #426

@jasondark

Description

@jasondark

The function into_float_with_exponent implements the standard bit-pattern hack to grab the 53 significant bits and subtract 1. However, according to http://xoshiro.di.unimi.it/ (see section "Generating uniform doubles in the unit interval") this halves the range of possible values by always resulting a least significant bit of zero. It is proposed to just use the more straight-forward (myint>>11) as f64 / (1u64 << 53) as f64 instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions