mirror of
https://github.com/uutils/coreutils
synced 2024-12-14 23:32:39 +00:00
std:num::pow -> std::num::Int::pow
This commit is contained in:
parent
fd2b464a6d
commit
e874d09216
3 changed files with 8 additions and 8 deletions
|
@ -9,11 +9,10 @@
|
||||||
|
|
||||||
use FmtOptions;
|
use FmtOptions;
|
||||||
use parasplit::{Paragraph, ParaWords, WordInfo};
|
use parasplit::{Paragraph, ParaWords, WordInfo};
|
||||||
use std::num::{Float, SignedInt};
|
use std::num::{Float, Int, SignedInt};
|
||||||
use std::i64;
|
use std::i64;
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::num;
|
|
||||||
|
|
||||||
struct BreakArgs<'a> {
|
struct BreakArgs<'a> {
|
||||||
opts : &'a FmtOptions,
|
opts : &'a FmtOptions,
|
||||||
|
@ -373,7 +372,7 @@ fn compute_demerits(delta_len: int, stretch: int, wlen: int, prev_rat: f32) -> (
|
||||||
// we penalize lines that have very different ratios from previous lines
|
// we penalize lines that have very different ratios from previous lines
|
||||||
let bad_delta_r = (DR_MULT * (((ratio - prev_rat) / 2.0).powf(3f32)).abs()) as i64;
|
let bad_delta_r = (DR_MULT * (((ratio - prev_rat) / 2.0).powf(3f32)).abs()) as i64;
|
||||||
|
|
||||||
let demerits = num::pow(1 + bad_linelen + bad_wordlen + bad_delta_r, 2);
|
let demerits = Int::pow(1 + bad_linelen + bad_wordlen + bad_delta_r, 2);
|
||||||
|
|
||||||
(demerits, ratio)
|
(demerits, ratio)
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ extern crate getopts;
|
||||||
use std::io::{stdin};
|
use std::io::{stdin};
|
||||||
use std::io::BufferedReader;
|
use std::io::BufferedReader;
|
||||||
use std::io::fs::File;
|
use std::io::fs::File;
|
||||||
|
use std::num::Int;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use getopts::{optopt, optflag, getopts, usage, OptGroup};
|
use getopts::{optopt, optflag, getopts, usage, OptGroup};
|
||||||
|
|
||||||
|
@ -164,7 +165,7 @@ fn nl<T: Reader> (reader: &mut BufferedReader<T>, settings: &Settings) {
|
||||||
let line_no_width_initial = line_no_width;
|
let line_no_width_initial = line_no_width;
|
||||||
// Stores the smallest integer with one more digit than line_no, so that
|
// 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.
|
// when line_no >= line_no_threshold, we need to use one more digit.
|
||||||
let mut line_no_threshold = std::num::pow(10u64, line_no_width);
|
let mut line_no_threshold = Int::pow(10u64, line_no_width);
|
||||||
let mut empty_line_count: u64 = 0;
|
let mut empty_line_count: u64 = 0;
|
||||||
let fill_char = match settings.number_format {
|
let fill_char = match settings.number_format {
|
||||||
NumberFormat::RightZero => '0',
|
NumberFormat::RightZero => '0',
|
||||||
|
@ -226,7 +227,7 @@ fn nl<T: Reader> (reader: &mut BufferedReader<T>, settings: &Settings) {
|
||||||
if settings.renumber {
|
if settings.renumber {
|
||||||
line_no = settings.starting_line_number;
|
line_no = settings.starting_line_number;
|
||||||
line_no_width = line_no_width_initial;
|
line_no_width = line_no_width_initial;
|
||||||
line_no_threshold = std::num::pow(10u64, line_no_width);
|
line_no_threshold = Int::pow(10u64, line_no_width);
|
||||||
}
|
}
|
||||||
&settings.header_numbering
|
&settings.header_numbering
|
||||||
},
|
},
|
||||||
|
|
|
@ -15,7 +15,7 @@ extern crate getopts;
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
|
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::num;
|
use std::num::Int;
|
||||||
use std::char;
|
use std::char;
|
||||||
|
|
||||||
#[path = "../common/util.rs"]
|
#[path = "../common/util.rs"]
|
||||||
|
@ -193,7 +193,7 @@ fn str_prefix(i: uint, width: uint) -> String {
|
||||||
let mut w = width;
|
let mut w = width;
|
||||||
while w > 0 {
|
while w > 0 {
|
||||||
w -= 1;
|
w -= 1;
|
||||||
let div = num::pow(26 as uint, w);
|
let div = Int::pow(26 as uint, w);
|
||||||
let r = n / div;
|
let r = n / div;
|
||||||
n -= r * div;
|
n -= r * div;
|
||||||
c.push(char::from_u32((r as u32) + 97).unwrap());
|
c.push(char::from_u32((r as u32) + 97).unwrap());
|
||||||
|
@ -208,7 +208,7 @@ fn num_prefix(i: uint, width: uint) -> String {
|
||||||
let mut w = width;
|
let mut w = width;
|
||||||
while w > 0 {
|
while w > 0 {
|
||||||
w -= 1;
|
w -= 1;
|
||||||
let div = num::pow(10 as uint, w);
|
let div = Int::pow(10 as uint, w);
|
||||||
let r = n / div;
|
let r = n / div;
|
||||||
n -= r * div;
|
n -= r * div;
|
||||||
c.push(char::from_digit(r, 10).unwrap());
|
c.push(char::from_digit(r, 10).unwrap());
|
||||||
|
|
Loading…
Reference in a new issue