Skip to content

Implement rational() function for floats #11125

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Dec 30, 2013
Merged

Conversation

vmx
Copy link
Contributor

@vmx vmx commented Dec 23, 2013

The Ratio::rational() converts a float (f32 and f64) into a
Ratio.

Closes #9838

@@ -107,6 +107,27 @@ impl<T: Clone + Integer + Ord>
}
}

impl Ratio<BigInt> {
/// Converts a float into a rational number
pub fn rational<T: Float>(f: T) -> Option<BigRational> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be from_float?

@huonw
Copy link
Member

huonw commented Dec 26, 2013

Could you squash the commits? (r=me when done, make sure to comment here when you've done it, because we don't get automatic notifications when a PR is updated. :) )

The Ratio::from_float() converts a float (f32 and f64) into a
Ratio<BigInt>.

Closes rust-lang#9838
bors added a commit that referenced this pull request Dec 30, 2013
The Ratio::rational() converts a float (f32 and f64) into a
Ratio<BigInt>.

Closes #9838
@bors bors closed this Dec 30, 2013
@bors bors merged commit e0a6910 into rust-lang:master Dec 30, 2013
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants