Skip to content

Convertion of negative f64 to u64. #72899

Closed
@aslpavel

Description

@aslpavel

I tried this code:

let v: f64 = -10.0;
println!("{}", v as u64);
let v: f32 = -10.0;
println!("{}", v as u64);

I expected to see this happen:
Should print

0
0

Instead, this happened:
Stable: 1.43.1

140731856997200
0

Beta channel
Build using the Beta version: 1.44.0-beta.4
(2020-05-23 02c25b3)

1
0

This one is actually correct. Sorry if it has been fixed, I have not found bug report for this, so I've decided to create this one.
Nightly channel
Build using the Nightly version: 1.45.0-nightly
(2020-05-31 5fd2f06)

0
0

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions