You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Doesn't work as expected that is. Reasoning by analogy with the int modules I would expect that float::round(5.8) returns 6.0, but instead you get: error: mismatched types: expected core::libc::types::os::arch::c95::c_double but found float.
Looking at the code I expect that more that just round has this problem.
This is because c_double is a typedef for f64, and f64 and float are not type compatible (they used to be). Most of the float functions are just reexports of bindings to the C math libraries.
The easiest fix is to write wrapper functions in core::float that cast to the right type (will be a noop).
Beyond that it might be nice to think about how to get rid of the duplication between float/f32/f64.
The specific code in question appears to have been fixed in d9c54f8, although
it turns out that std::float::round == std::f64::round always, so std::float::round(2.3f) is actually a failure. I think this should be a
separate issue, however (one that probably wants removal of a number of
top-level functions in the numeric modules.
I believe the preferred method is now 3.2f.round(). This won't work for
literals (3.2.round() has multiple methods applicable in scope), but it would
work for any floating type which is inferred somewhere else (to be expected).
I'm going to close this saying that it's been fixed, but if others feel
differently I can definitely reopen.
Activity
brson commentedon Aug 25, 2012
This is because c_double is a typedef for f64, and f64 and float are not type compatible (they used to be). Most of the float functions are just reexports of bindings to the C math libraries.
The easiest fix is to write wrapper functions in core::float that cast to the right type (will be a noop).
Beyond that it might be nice to think about how to get rid of the duplication between float/f32/f64.
catamorphism commentedon Jan 30, 2013
3e9c95e fixes the specific problem with
round. @brson, I'm not sure if the other issues you pointed out still apply or not.catamorphism commentedon Jan 30, 2013
(sorry, clicked close by mistake)
alexcrichton commentedon Jul 1, 2013
The specific code in question appears to have been fixed in d9c54f8, although
it turns out that std::float::round == std::f64::round always, so
std::float::round(2.3f)is actually a failure. I think this should be aseparate issue, however (one that probably wants removal of a number of
top-level functions in the numeric modules.
I believe the preferred method is now
3.2f.round(). This won't work forliterals (
3.2.round()has multiple methods applicable in scope), but it wouldwork for any floating type which is inferred somewhere else (to be expected).
I'm going to close this saying that it's been fixed, but if others feel
differently I can definitely reopen.
Auto merge of rust-lang#3281 - RalfJung:typo, r=RalfJung
Deprecate `--visualize` in favor of concrete playback (rust-lang#3281)
disable invert if assist for if-let to fix rust-lang#3281
Merge rust-lang#3668