diff --git a/src/lib/math.rs b/src/lib/math.rs index c880217ce8da..7b4308668b48 100644 --- a/src/lib/math.rs +++ b/src/lib/math.rs @@ -1,4 +1,9 @@ -/* Module: math */ +/* + +Module: math + +Floating point operations and constants for `float`s +*/ export consts; export min, max; @@ -15,7 +20,7 @@ export import ctypes::c_float; import ctypes::c_int; -import c_float = f64; +import c_float = math_f64; // FIXME replace with redirect to c_float::consts::FOO as soon as it works mod consts { diff --git a/src/lib/f32.rs b/src/lib/math_f32.rs similarity index 90% rename from src/lib/f32.rs rename to src/lib/math_f32.rs index fad7cd1110be..2172c9f8a99c 100644 --- a/src/lib/f32.rs +++ b/src/lib/math_f32.rs @@ -1,3 +1,13 @@ + +/* +Module: math_f32 + +Floating point operations and constants for `f32` + +This exposes the same operations as `math`, just for `f32` even though +they do not show up in the docs right now! +*/ + import cmath::f32::*; export diff --git a/src/lib/f64.rs b/src/lib/math_f64.rs similarity index 90% rename from src/lib/f64.rs rename to src/lib/math_f64.rs index b94e3dfe5db7..639dc4a29b25 100644 --- a/src/lib/f64.rs +++ b/src/lib/math_f64.rs @@ -1,3 +1,13 @@ + +/* +Module: math_f64 + +Floating point operations and constants for `f64`s + +This exposes the same operations as `math`, just for `f64` even though +they do not show up in the docs right now! +*/ + import cmath::f64::*; export diff --git a/src/lib/std.rc b/src/lib/std.rc index 97714d959ae9..342e3fe394d1 100644 --- a/src/lib/std.rc +++ b/src/lib/std.rc @@ -7,13 +7,14 @@ #[license = "BSD"]; -export box, char, float, f32, f64, int, str, ptr; -export uint, u8, u32, u64, vec, bool; +export box, char, float, int, str, ptr; +export uint, u8, u32, u64, vec, bool; export comm, fs, io, net, run, sys, task; export ctypes, either, option, result, four, tri, util; export bitv, deque, fun_treemap, list, map, smallintmap, sort, treemap, ufind; export rope; -export ebml, dbg, getopts, json, math, rand, sha1, term, time, unsafe; +export math, math_f32, math_f64; +export ebml, dbg, getopts, json, rand, sha1, term, time, unsafe; export extfmt, test, tempfile; // FIXME: generic_os and os_fs shouldn't be exported export generic_os, os, os_fs; @@ -24,8 +25,6 @@ export generic_os, os, os_fs; mod box; mod char; mod float; -mod f32; -mod f64; mod int; mod str; mod ptr; @@ -82,6 +81,8 @@ mod dbg; mod getopts; mod json; mod math; +mod math_f32; +mod math_f64; mod rand; mod sha1; mod tempfile; diff --git a/src/test/stdtest/math.rs b/src/test/stdtest/math.rs index 458d3e1a9056..39b72e680782 100644 --- a/src/test/stdtest/math.rs +++ b/src/test/stdtest/math.rs @@ -20,6 +20,7 @@ fn test_max_min() { fn test_trig() { assert sin(0.0) == 0.0; assert sin(-0.0) == 0.0; + assert float::isNaN(sin(float::infinity)); assert float::isNaN(sin(float::neg_infinity)); @@ -259,7 +260,7 @@ fn test_log_functions() { assert log10(1.0) == 0.0; // FIXME remove round-up due to valgrind weirdness - assert ceil(ln(consts::e)) /* ln(e) == 0.999.. under valgrind */ + assert ceil(ln(consts::e)) == 1.0; /* ln(e) == 0.999.. under valgrind */ assert log2(2.0) == 1.0; assert log10(10.0) == 1.0;