1 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 //! Operations and constants for unsigned 64-bits integer (`u64` type)
13 #![allow(non_uppercase_statics)]
18 use from_str::FromStr;
19 use num::{Bitwise, Bounded};
20 #[cfg(target_word_size = "64")]
22 use num::{CheckedAdd, CheckedSub};
23 use num::{CheckedDiv, Zero, One, strconv};
24 use num::{ToStrRadix, FromStrRadix};
25 use option::{Option, Some, None};
29 uint_module!(u64, i64, 64)
31 impl CheckedAdd for u64 {
33 fn checked_add(&self, v: &u64) -> Option<u64> {
35 let (x, y) = intrinsics::u64_add_with_overflow(*self, *v);
36 if y { None } else { Some(x) }
41 impl CheckedSub for u64 {
43 fn checked_sub(&self, v: &u64) -> Option<u64> {
45 let (x, y) = intrinsics::u64_sub_with_overflow(*self, *v);
46 if y { None } else { Some(x) }
51 impl CheckedMul for u64 {
53 fn checked_mul(&self, v: &u64) -> Option<u64> {
55 let (x, y) = intrinsics::u64_mul_with_overflow(*self, *v);
56 if y { None } else { Some(x) }