Skip to content

Unexpected results from unsafe Type castingΒ #1666

Open
@tiberiumboy

Description

@tiberiumboy

Under type/cast.md, the example below:
unsafe { // -100.0 as u8 is 156 println!("-100.0 as u8 is : {}", (-100.0_f32).to_int_unchecked::<u8>()); }
returns 0 as undefined behavior rather than 156 as expected result.
Please update the documentation accordingly so that it doesn't confuse the reader who compiles this code on their local machine.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions