- 
                Notifications
    You must be signed in to change notification settings 
- Fork 78
Closed
Description
NotNaN's implementation prevents binary operators from receiving a NaN operand, but this is far from the only way that a NaN may arise;
NaN, the menace that it is, is something that all numeric binary operations are capable of producing!
fn main() {
    let zero = NotNaN::new(0.).unwrap();
    let infinity = NotNaN::new(1./0.).unwrap();
    println!("{:?}", infinity + (-infinity)); // ==> NotNaN(NaN)
    println!("{:?}", infinity - infinity);    // ==> NotNaN(NaN)
    println!("{:?}", zero * infinity);        // ==> NotNaN(NaN)
    println!("{:?}", zero / zero);            // ==> NotNaN(NaN)
    println!("{:?}", zero % zero);            // ==> NotNaN(NaN)
}Notice that due to unsafe optimizations in NotNaN, this enables undefined behavior in safe code.
Metadata
Metadata
Assignees
Labels
No labels