Integer type changes

This commit is contained in:
Michael Gehring 2015-03-08 19:06:30 +01:00
parent bce3382fd2
commit 9f8fd55b4a
4 changed files with 7 additions and 7 deletions

View file

@ -167,7 +167,7 @@ fn nl<T: Reader> (reader: &mut BufferedReader<T>, settings: &Settings) {
let line_no_width_initial = line_no_width;
// Stores the smallest integer with one more digit than line_no, so that
// when line_no >= line_no_threshold, we need to use one more digit.
let mut line_no_threshold = Int::pow(10u64, line_no_width);
let mut line_no_threshold = Int::pow(10u64, line_no_width as u32);
let mut empty_line_count: u64 = 0;
let fill_char = match settings.number_format {
NumberFormat::RightZero => '0',
@ -229,7 +229,7 @@ fn nl<T: Reader> (reader: &mut BufferedReader<T>, settings: &Settings) {
if settings.renumber {
line_no = settings.starting_line_number;
line_no_width = line_no_width_initial;
line_no_threshold = Int::pow(10u64, line_no_width);
line_no_threshold = Int::pow(10u64, line_no_width as u32);
}
&settings.header_numbering
},

View file

@ -73,12 +73,12 @@ fn main(input_offset_base: &Radix, fname: &str) {
match f.read(bytes) {
Ok(n) => {
print_with_radix(input_offset_base, addr);
for b in range(0, n / std::u16::BYTES) {
for b in range(0, n / std::u16::BYTES as usize) {
let bs = &bytes[(2 * b) .. (2 * b + 2)];
let p: u16 = (bs[1] as u16) << 8 | bs[0] as u16;
print!(" {:06o}", p);
}
if n % std::u16::BYTES == 1 {
if n % std::u16::BYTES as usize == 1 {
print!(" {:06o}", bytes[n - 1]);
}
print!("\n");

View file

@ -225,7 +225,7 @@ fn str_prefix(i: usize, width: usize) -> String {
let mut w = width;
while w > 0 {
w -= 1;
let div = Int::pow(26 as usize, w);
let div = Int::pow(26 as usize, w as u32);
let r = n / div;
n -= r * div;
c.push(char::from_u32((r as u32) + 97).unwrap());
@ -240,7 +240,7 @@ fn num_prefix(i: usize, width: usize) -> String {
let mut w = width;
while w > 0 {
w -= 1;
let div = Int::pow(10 as usize, w);
let div = Int::pow(10 as usize, w as u32);
let r = n / div;
n -= r * div;
c.push(char::from_digit(r as u32, 10).unwrap());

View file

@ -101,7 +101,7 @@ fn parse_size(size: &str) -> Option<u64> {
Some(m) => m,
None => return None,
};
let (power, base): (usize, u64) = match ext {
let (power, base): (u32, u64) = match ext {
"" => (0, 0),
"KB" => (1, 1024),
"K" => (1, 1000),