core: Add compl functions for the rest of the integer types
This commit is contained in:
parent
2784314a1f
commit
acc57a44fd
@ -29,3 +29,8 @@ fn range(lo: i16, hi: i16, it: fn(i16)) {
|
||||
let i = lo;
|
||||
while i < hi { it(i); i += 1i16; }
|
||||
}
|
||||
|
||||
#[doc = "Computes the bitwise complement"]
|
||||
fn compl(i: i16) -> i16 {
|
||||
u16::compl(i as u16) as i16
|
||||
}
|
||||
|
@ -29,3 +29,8 @@ fn range(lo: i32, hi: i32, it: fn(i32)) {
|
||||
let i = lo;
|
||||
while i < hi { it(i); i += 1i32; }
|
||||
}
|
||||
|
||||
#[doc = "Computes the bitwise complement"]
|
||||
fn compl(i: i32) -> i32 {
|
||||
u32::compl(i as u32) as i32
|
||||
}
|
||||
|
@ -29,3 +29,8 @@ fn range(lo: i64, hi: i64, it: fn(i64)) {
|
||||
let i = lo;
|
||||
while i < hi { it(i); i += 1i64; }
|
||||
}
|
||||
|
||||
#[doc = "Computes the bitwise complement"]
|
||||
fn compl(i: i64) -> i64 {
|
||||
u64::compl(i as u64) as i64
|
||||
}
|
||||
|
@ -29,3 +29,8 @@ fn range(lo: i8, hi: i8, it: fn(i8)) {
|
||||
let i = lo;
|
||||
while i < hi { it(i); i += 1i8; }
|
||||
}
|
||||
|
||||
#[doc = "Computes the bitwise complement"]
|
||||
fn compl(i: i8) -> i8 {
|
||||
u8::compl(i as u8) as i8
|
||||
}
|
||||
|
@ -186,6 +186,11 @@ fn pow(base: int, exponent: uint) -> int {
|
||||
ret acc;
|
||||
}
|
||||
|
||||
#[doc = "Computes the bitwise complement"]
|
||||
fn compl(i: int) -> int {
|
||||
uint::compl(i as uint) as int
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_from_str() {
|
||||
assert(from_str("0") == 0);
|
||||
|
@ -29,3 +29,8 @@ fn range(lo: u16, hi: u16, it: fn(u16)) {
|
||||
let i = lo;
|
||||
while i < hi { it(i); i += 1u16; }
|
||||
}
|
||||
|
||||
#[doc = "Computes the bitwise complement"]
|
||||
fn compl(i: u16) -> u16 {
|
||||
max_value ^ i
|
||||
}
|
||||
|
@ -64,6 +64,11 @@ fn range(lo: u32, hi: u32, it: fn(u32)) {
|
||||
while i < hi { it(i); i += 1u32; }
|
||||
}
|
||||
|
||||
#[doc = "Computes the bitwise complement"]
|
||||
fn compl(i: u32) -> u32 {
|
||||
max_value ^ i
|
||||
}
|
||||
|
||||
//
|
||||
// Local Variables:
|
||||
// mode: rust
|
||||
|
@ -134,3 +134,8 @@ fn from_str(buf: str, radix: u64) -> u64 {
|
||||
}
|
||||
fail;
|
||||
}
|
||||
|
||||
#[doc = "Computes the bitwise complement"]
|
||||
fn compl(i: u64) -> u64 {
|
||||
max_value ^ i
|
||||
}
|
||||
|
@ -64,6 +64,11 @@ fn range(lo: u8, hi: u8, it: fn(u8)) {
|
||||
while i < hi { it(i); i += 1u8; }
|
||||
}
|
||||
|
||||
#[doc = "Computes the bitwise complement"]
|
||||
fn compl(i: u8) -> u8 {
|
||||
max_value ^ i
|
||||
}
|
||||
|
||||
// Local Variables:
|
||||
// mode: rust;
|
||||
// fill-column: 78;
|
||||
|
@ -274,7 +274,7 @@ Function: compl
|
||||
Computes the bitwise complement.
|
||||
*/
|
||||
fn compl(i: uint) -> uint {
|
||||
uint::max_value ^ i
|
||||
max_value ^ i
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user