File: arith-unsigned.rs

package info (click to toggle)
rustc 1.89.0%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 906,624 kB
  • sloc: xml: 158,148; python: 34,888; javascript: 19,595; sh: 19,221; ansic: 13,046; cpp: 7,144; asm: 4,376; makefile: 692; lisp: 174; sql: 15
file content (26 lines) | stat: -rw-r--r-- 774 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//@ run-pass
#![allow(unused_comparisons)]

// Unsigned integer operations
pub fn main() {
    assert!(0u8 < 255u8);
    assert!(0u8 <= 255u8);
    assert!(255u8 > 0u8);
    assert!(255u8 >= 0u8);
    assert_eq!(250u8 / 10u8, 25u8);
    assert_eq!(255u8 % 10u8, 5u8);
    assert!(0u16 < 60000u16);
    assert!(0u16 <= 60000u16);
    assert!(60000u16 > 0u16);
    assert!(60000u16 >= 0u16);
    assert_eq!(60000u16 / 10u16, 6000u16);
    assert_eq!(60005u16 % 10u16, 5u16);
    assert!(0u32 < 4000000000u32);
    assert!(0u32 <= 4000000000u32);
    assert!(4000000000u32 > 0u32);
    assert!(4000000000u32 >= 0u32);
    assert_eq!(4000000000u32 / 10u32, 400000000u32);
    assert_eq!(4000000005u32 % 10u32, 5u32);
    // 64-bit numbers have some flakiness yet. Not tested

}