Skip to content

Inline numeric operations for floats. #4026

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 24, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/libcore/float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,14 +436,22 @@ impl float : Ord {
}

impl float: num::Num {
#[inline(always)]
pub pure fn add(other: &float) -> float { return self + *other; }
#[inline(always)]
pub pure fn sub(other: &float) -> float { return self - *other; }
#[inline(always)]
pub pure fn mul(other: &float) -> float { return self * *other; }
#[inline(always)]
pub pure fn div(other: &float) -> float { return self / *other; }
#[inline(always)]
pure fn modulo(other: &float) -> float { return self % *other; }
#[inline(always)]
pure fn neg() -> float { return -self; }

#[inline(always)]
pure fn to_int() -> int { return self as int; }
#[inline(always)]
static pure fn from_int(n: int) -> float { return n as float; }
}

Expand Down