Moved generic float::min, max to core::math and cleaned up some imports
This commit is contained in:
parent
494ad4e601
commit
1f10ee365c
|
@ -129,7 +129,7 @@ fn get_relative_to(abs1: fs::path, abs2: fs::path) -> fs::path {
|
|||
assert len1 > 0u;
|
||||
assert len2 > 0u;
|
||||
|
||||
let max_common_path = float::min(len1, len2) - 1u;
|
||||
let max_common_path = math::min(len1, len2) - 1u;
|
||||
let start_idx = 0u;
|
||||
while start_idx < max_common_path
|
||||
&& split1[start_idx] == split2[start_idx] {
|
||||
|
|
|
@ -1765,7 +1765,7 @@ mod unify {
|
|||
let vb = alt cx.st {
|
||||
in_bindings(vb) { vb }
|
||||
};
|
||||
ufind::grow(vb.sets, float::max(set_a, set_b) + 1u);
|
||||
ufind::grow(vb.sets, math::max(set_a, set_b) + 1u);
|
||||
let root_a = ufind::find(vb.sets, set_a);
|
||||
let root_b = ufind::find(vb.sets, set_b);
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import core::{str, option};
|
||||
import core::float::{max, min};
|
||||
import math::{max, min};
|
||||
import std::map::hashmap;
|
||||
import option::{some};
|
||||
import syntax::ast;
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import core::{vec, str, int, uint, option, result};
|
||||
import std::{fs, io};
|
||||
|
||||
import rustc::syntax::{ast, ast_util, fold, visit, codemap};
|
||||
|
@ -241,9 +240,9 @@ fn check_variants_T<copy T>(
|
|||
let L = vec::len(things);
|
||||
|
||||
if L < 100u {
|
||||
under(float::min(L, 20u)) {|i|
|
||||
under(math::min(L, 20u)) {|i|
|
||||
log(error, "Replacing... #" + uint::str(i));
|
||||
under(float::min(L, 30u)) {|j|
|
||||
under(math::min(L, 30u)) {|j|
|
||||
log(error, "With... " + stringifier(@things[j]));
|
||||
let crate2 = @replacer(crate, i, things[j], cx.mode);
|
||||
// It would be best to test the *crate* for stability, but testing the
|
||||
|
|
|
@ -12,6 +12,7 @@ export uint, u8, u32, u64, vec, bool;
|
|||
export either, option, result;
|
||||
export ctypes, sys, unsafe, comm, task;
|
||||
export extfmt;
|
||||
export math;
|
||||
|
||||
// Built-in-type support modules
|
||||
|
||||
|
@ -45,6 +46,7 @@ mod result;
|
|||
// Runtime and language-primitive support
|
||||
|
||||
mod ctypes;
|
||||
mod math;
|
||||
mod cmath;
|
||||
mod sys;
|
||||
mod unsafe;
|
||||
|
|
|
@ -224,10 +224,16 @@ mod consts {
|
|||
const ln_10: f32 = 2.30258509299404568401799145468436421_f32;
|
||||
}
|
||||
|
||||
pure fn signbit(x: f32) -> int {
|
||||
if is_negative(x) { ret 1; } else { ret 0; }
|
||||
}
|
||||
|
||||
#[cfg(target_os="linux")]
|
||||
#[cfg(target_os="macos")]
|
||||
#[cfg(target_os="win32")]
|
||||
pure fn logarithm(n: f32, b: f32) -> f32 {
|
||||
// FIXME check if it is good to use log2 instead of ln here;
|
||||
// in theory should be faster since the radix is 2
|
||||
ret log2(n) / log2(b);
|
||||
}
|
||||
|
||||
|
|
|
@ -241,10 +241,16 @@ mod consts {
|
|||
const ln_10: f64 = 2.30258509299404568401799145468436421_f64;
|
||||
}
|
||||
|
||||
pure fn signbit(x: f64) -> int {
|
||||
if is_negative(x) { ret 1; } else { ret 0; }
|
||||
}
|
||||
|
||||
#[cfg(target_os="linux")]
|
||||
#[cfg(target_os="macos")]
|
||||
#[cfg(target_os="win32")]
|
||||
pure fn logarithm(n: f64, b: f64) -> f64 {
|
||||
// FIXME check if it is good to use log2 instead of ln here;
|
||||
// in theory should be faster since the radix is 2
|
||||
ret log2(n) / log2(b);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ Module: float
|
|||
|
||||
// FIXME find out why these have to be exported explicitly
|
||||
|
||||
export to_str_common, to_str_exact, to_str, from_str, min, max;
|
||||
export to_str_common, to_str_exact, to_str, from_str;
|
||||
export add, sub, mul, div, rem, lt, le, gt, eq, eq, ne;
|
||||
export is_positive, is_negative, is_nonpositive, is_nonnegative;
|
||||
export is_zero, is_infinite, is_finite;
|
||||
|
@ -16,6 +16,7 @@ export erf, erfc, exp, expm1, exp2, abs, abs_sub;
|
|||
export mul_add, fmax, fmin, nextafter, frexp, hypot, ldexp;
|
||||
export lgamma, ln, log_radix, ln1p, log10, log2, ilog_radix;
|
||||
export modf, pow, round, sin, sinh, sqrt, tan, tanh, tgamma, trunc;
|
||||
export signbit;
|
||||
|
||||
// export when m_float == c_double
|
||||
|
||||
|
@ -280,20 +281,6 @@ fn pow_uint_to_uint_as_float(x: uint, pow: uint) -> float {
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
Function: min
|
||||
|
||||
Returns the minimum of two values
|
||||
*/
|
||||
pure fn min<copy T>(x: T, y: T) -> T { x < y ? x : y }
|
||||
|
||||
/*
|
||||
Function: max
|
||||
|
||||
Returns the maximum of two values
|
||||
*/
|
||||
pure fn max<copy T>(x: T, y: T) -> T { x < y ? y : x }
|
||||
|
||||
//
|
||||
// Local Variables:
|
||||
// mode: rust
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
// Generic functions that have been defined for all numeric types
|
||||
//
|
||||
// (may very well go away again soon)
|
||||
|
||||
/*
|
||||
Function: min
|
||||
|
||||
Returns the minimum of two values
|
||||
*/
|
||||
pure fn min<copy T>(x: T, y: T) -> T { x < y ? x : y }
|
||||
|
||||
/*
|
||||
Function: max
|
||||
|
||||
Returns the maximum of two values
|
||||
*/
|
||||
pure fn max<copy T>(x: T, y: T) -> T { x < y ? y : x }
|
||||
|
|
@ -26,10 +26,6 @@ The following operations are algorithmically faster in ropes:
|
|||
*/
|
||||
|
||||
|
||||
import core::option;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Type: rope
|
||||
|
||||
|
@ -1103,7 +1099,7 @@ mod node {
|
|||
right : right,
|
||||
char_len: char_len(left) + char_len(right),
|
||||
byte_len: byte_len(left) + byte_len(right),
|
||||
height: float::max(height(left), height(right)) + 1u
|
||||
height: math::max(height(left), height(right)) + 1u
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ import core::*;
|
|||
|
||||
use std;
|
||||
|
||||
import math::{min, max};
|
||||
import float::*;
|
||||
import float;
|
||||
import c_int = ctypes::c_int;
|
||||
|
|
Loading…
Reference in New Issue