diff --git a/src/libcore/f32.rs b/src/libcore/f32.rs index 89a8bfa424f..e1d30081966 100644 --- a/src/libcore/f32.rs +++ b/src/libcore/f32.rs @@ -184,6 +184,7 @@ impl num of num for f32 { fn mul(&&other: f32) -> f32 { ret self * other; } fn div(&&other: f32) -> f32 { ret self / other; } fn modulo(&&other: f32) -> f32 { ret self % other; } + fn neg() -> f32 { ret -self; } fn to_int() -> int { ret self as int; } fn from_int(n: int) -> f32 { ret n as f32; } diff --git a/src/libcore/f64.rs b/src/libcore/f64.rs index 151b90d4fcb..af83a0829e1 100644 --- a/src/libcore/f64.rs +++ b/src/libcore/f64.rs @@ -205,6 +205,7 @@ impl num of num for f64 { fn mul(&&other: f64) -> f64 { ret self * other; } fn div(&&other: f64) -> f64 { ret self / other; } fn modulo(&&other: f64) -> f64 { ret self % other; } + fn neg() -> f64 { ret -self; } fn to_int() -> int { ret self as int; } fn from_int(n: int) -> f64 { ret n as f64; } diff --git a/src/libcore/float.rs b/src/libcore/float.rs index a2b5197277a..d55c0e0c371 100644 --- a/src/libcore/float.rs +++ b/src/libcore/float.rs @@ -416,6 +416,7 @@ impl num of num for float { fn mul(&&other: float) -> float { ret self * other; } fn div(&&other: float) -> float { ret self / other; } fn modulo(&&other: float) -> float { ret self % other; } + fn neg() -> float { ret -self; } fn to_int() -> int { ret self as int; } fn from_int(n: int) -> float { ret n as float; } diff --git a/src/libcore/int-template.rs b/src/libcore/int-template.rs index 8d9225b05a8..556b9944dde 100644 --- a/src/libcore/int-template.rs +++ b/src/libcore/int-template.rs @@ -129,6 +129,7 @@ impl num of num for T { fn mul(&&other: T) -> T { ret self * other; } fn div(&&other: T) -> T { ret self / other; } fn modulo(&&other: T) -> T { ret self % other; } + fn neg() -> T { ret -self; } fn to_int() -> int { ret self as int; } fn from_int(n: int) -> T { ret n as T; } diff --git a/src/libcore/num.rs b/src/libcore/num.rs index 7d57f7ff55b..eb5073c14b8 100644 --- a/src/libcore/num.rs +++ b/src/libcore/num.rs @@ -8,6 +8,7 @@ iface num { fn mul(&&other: self) -> self; fn div(&&other: self) -> self; fn modulo(&&other: self) -> self; + fn neg() -> self; fn to_int() -> int; fn from_int(n: int) -> self; // TODO: Static functions. diff --git a/src/libcore/uint-template.rs b/src/libcore/uint-template.rs index 9d658605f5a..d1d238d298c 100644 --- a/src/libcore/uint-template.rs +++ b/src/libcore/uint-template.rs @@ -70,6 +70,7 @@ impl num of num for T { fn mul(&&other: T) -> T { ret self * other; } fn div(&&other: T) -> T { ret self / other; } fn modulo(&&other: T) -> T { ret self % other; } + fn neg() -> T { ret -self; } fn to_int() -> int { ret self as int; } fn from_int(n: int) -> T { ret n as T; }