std: math: renaming and documentation fixes

This commit is contained in:
Stefan Plantikow 2011-11-24 20:43:33 +01:00 committed by Brian Anderson
parent 97fc39b214
commit 891528fb73
5 changed files with 35 additions and 8 deletions

View File

@ -1,4 +1,9 @@
/* Module: math */ /*
Module: math
Floating point operations and constants for `float`s
*/
export consts; export consts;
export min, max; export min, max;
@ -15,7 +20,7 @@ export
import ctypes::c_float; import ctypes::c_float;
import ctypes::c_int; 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 // FIXME replace with redirect to c_float::consts::FOO as soon as it works
mod consts { mod consts {

View File

@ -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::*; import cmath::f32::*;
export export

View File

@ -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::*; import cmath::f64::*;
export export

View File

@ -7,13 +7,14 @@
#[license = "BSD"]; #[license = "BSD"];
export box, char, float, f32, f64, int, str, ptr; export box, char, float, int, str, ptr;
export uint, u8, u32, u64, vec, bool; export uint, u8, u32, u64, vec, bool;
export comm, fs, io, net, run, sys, task; export comm, fs, io, net, run, sys, task;
export ctypes, either, option, result, four, tri, util; export ctypes, either, option, result, four, tri, util;
export bitv, deque, fun_treemap, list, map, smallintmap, sort, treemap, ufind; export bitv, deque, fun_treemap, list, map, smallintmap, sort, treemap, ufind;
export rope; 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; export extfmt, test, tempfile;
// FIXME: generic_os and os_fs shouldn't be exported // FIXME: generic_os and os_fs shouldn't be exported
export generic_os, os, os_fs; export generic_os, os, os_fs;
@ -24,8 +25,6 @@ export generic_os, os, os_fs;
mod box; mod box;
mod char; mod char;
mod float; mod float;
mod f32;
mod f64;
mod int; mod int;
mod str; mod str;
mod ptr; mod ptr;
@ -82,6 +81,8 @@ mod dbg;
mod getopts; mod getopts;
mod json; mod json;
mod math; mod math;
mod math_f32;
mod math_f64;
mod rand; mod rand;
mod sha1; mod sha1;
mod tempfile; mod tempfile;

View File

@ -20,6 +20,7 @@ fn test_max_min() {
fn test_trig() { fn test_trig() {
assert sin(0.0) == 0.0; assert sin(0.0) == 0.0;
assert sin(-0.0) == 0.0; assert sin(-0.0) == 0.0;
assert float::isNaN(sin(float::infinity)); assert float::isNaN(sin(float::infinity));
assert float::isNaN(sin(float::neg_infinity)); assert float::isNaN(sin(float::neg_infinity));
@ -259,7 +260,7 @@ fn test_log_functions() {
assert log10(1.0) == 0.0; assert log10(1.0) == 0.0;
// FIXME remove round-up due to valgrind weirdness // 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 log2(2.0) == 1.0;
assert log10(10.0) == 1.0; assert log10(10.0) == 1.0;