swift语言点评六-Numbers and Basic Values

本文深入介绍了Swift中的数值类型,包括布尔值、整数、浮点数等基本数值类型,以及范围类型、错误处理协议和可选类型。同时探讨了如何使用数值协议编写泛型代码,介绍了特殊用途的数值类型,并提供了全局数值函数的使用方法。

Topics

Logical Values

struct Bool

A value type whose instances are either true or false.

Numeric Values

struct Int

A signed integer value type.

struct Double

A double-precision, floating-point value type.

struct Float

A single-precision, floating-point value type.

Ranges

struct Range

A half-open interval over a comparable type, from a lower bound up to, but not including, an upper bound.

struct ClosedRange

An interval over a comparable type, from a lower bound up to, and including, an upper bound.

Errors

protocol Error

A type representing an error value that can be thrown.

Optionals

enum Optional

A type that represents either a wrapped value or nil, the absence of a value.

Advanced Numerics

Numeric Protocols

Write generic code that works with any numeric type.

Special-Use Numeric Types

Work with fixed-width numeric types of different sizes.

Global Numeric Functions

Use these functions with numeric values and other comparable types.

See Also

Values and Collections

Strings and Text

Work with text using Unicode-safe strings.

Collections

Store and organize data using arrays, dictionaries, sets, and other data structures.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值