Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
4f65fc7e
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4f65fc7e
编写于
7月 30, 2013
作者:
B
Brendan Zabarauskas
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improve std::num module description, and fix some formatting
上级
b6ea0538
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
4 addition
and
21 deletion
+4
-21
src/libstd/num/num.rs
src/libstd/num/num.rs
+4
-21
未找到文件。
src/libstd/num/num.rs
浏览文件 @
4f65fc7e
...
...
@@ -8,7 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//! An interface for numeric types
//! Numeric traits and functions for generic mathematics.
//!
//! These are implemented for the primitive numeric types in `std::{u8, u16,
//! u32, u64, uint, i8, i16, i32, i64, int, f32, f64, float}`.
#[allow(missing_doc)]
;
...
...
@@ -19,9 +22,7 @@
pub
mod
strconv
;
///
/// The base trait for numeric types
///
pub
trait
Num
:
Eq
+
Zero
+
One
+
Neg
<
Self
>
+
Add
<
Self
,
Self
>
...
...
@@ -188,9 +189,7 @@ pub trait Hyperbolic: Exponential {
#[inline(always)]
pub
fn
acosh
<
T
:
Hyperbolic
>
(
value
:
T
)
->
T
{
value
.acosh
()
}
#[inline(always)]
pub
fn
atanh
<
T
:
Hyperbolic
>
(
value
:
T
)
->
T
{
value
.atanh
()
}
///
/// Defines constants and methods common to real numbers
///
pub
trait
Real
:
Signed
+
Fractional
+
Algebraic
...
...
@@ -221,9 +220,7 @@ pub trait Real: Signed
fn
to_radians
(
&
self
)
->
Self
;
}
///
/// Methods that are harder to implement and not commonly used.
///
pub
trait
RealExt
:
Real
{
// FIXME (#5527): usages of `int` should be replaced with an associated
// integer type once these are implemented
...
...
@@ -241,9 +238,7 @@ pub trait RealExt: Real {
fn
yn
(
&
self
,
n
:
int
)
->
Self
;
}
///
/// Collects the bitwise operators under one trait.
///
pub
trait
Bitwise
:
Not
<
Self
>
+
BitAnd
<
Self
,
Self
>
+
BitOr
<
Self
,
Self
>
...
...
@@ -263,11 +258,9 @@ pub trait Bounded {
fn
max_value
()
->
Self
;
}
///
/// Specifies the available operations common to all of Rust's core numeric primitives.
/// These may not always make sense from a purely mathematical point of view, but
/// may be useful for systems programming.
///
pub
trait
Primitive
:
Num
+
NumCast
+
Bounded
...
...
@@ -282,17 +275,13 @@ pub trait Primitive: Num
fn
bytes
()
->
uint
;
}
///
/// A collection of traits relevant to primitive signed and unsigned integers
///
pub
trait
Int
:
Integer
+
Primitive
+
Bitwise
+
BitCount
{}
///
/// Used for representing the classification of floating point numbers
///
#[deriving(Eq)]
pub
enum
FPCategory
{
/// "Not a Number", often obtained by dividing by zero
...
...
@@ -307,9 +296,7 @@ pub enum FPCategory {
FPNormal
,
}
///
/// Primitive floating point numbers
///
pub
trait
Float
:
Real
+
Signed
+
Primitive
...
...
@@ -343,7 +330,6 @@ pub trait Float: Real
fn
next_after
(
&
self
,
other
:
Self
)
->
Self
;
}
///
#[inline(always)]
pub
fn
exp_m1
<
T
:
Float
>
(
value
:
T
)
->
T
{
value
.exp_m1
()
}
#[inline(always)]
pub
fn
ln_1p
<
T
:
Float
>
(
value
:
T
)
->
T
{
value
.ln_1p
()
}
#[inline(always)]
pub
fn
mul_add
<
T
:
Float
>
(
a
:
T
,
b
:
T
,
c
:
T
)
->
T
{
a
.mul_add
(
b
,
c
)
}
...
...
@@ -362,9 +348,7 @@ pub fn cast<T:NumCast,U:NumCast>(n: T) -> U {
NumCast
::
from
(
n
)
}
///
/// An interface for casting between machine scalars
///
pub
trait
NumCast
{
fn
from
<
T
:
NumCast
>
(
n
:
T
)
->
Self
;
...
...
@@ -436,7 +420,6 @@ pub trait FromStrRadix {
pub
fn
from_str_radix
(
str
:
&
str
,
radix
:
uint
)
->
Option
<
Self
>
;
}
///
/// Calculates a power to a given radix, optimized for uint `pow` and `radix`.
///
/// Returns `radix^pow` as `T`.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录