protocol
SignedInteger_
Inheritance |
Arithmetic, BinaryInteger, Comparable, CustomStringConvertible, Equatable, ExpressibleByIntegerLiteral, SignedArithmetic
View Protocol Hierarchy →
|
---|---|
Associated Types |
1 inherited item hidden. (Show all) |
Import |
|
Initializers
Declaration
init
<
T
where
T
:
BinaryInteger
>
(
extendingOrTruncating
source
:
T
)
Declared In
BinaryInteger
Creates an instance initialized to the specified integer value.
Do not call this initializer directly. Instead, initialize a variable or constant using an integer literal. For example:
let
x
=
23
In this example, the assignment to the x
constant calls this integer
literal initializer behind the scenes.
value
: The value to create.
Declaration
init
(
integerLiteral
value
:
Self
.
IntegerLiteralType
)
Declared In
ExpressibleByIntegerLiteral
6 inherited items hidden. (Show all)
Static Variables
1 inherited item hidden. (Show all)
Instance Variables
A textual representation of this instance.
Instead of accessing this property directly, convert an instance of any
type to a string by using the String(describing:)
initializer. For
example:
struct
Point
:
CustomStringConvertible
{
let
x
:
Int
,
y
:
Int
var
description
:
String
{
return
"(\(
x
), \(
y
))"
}
}
let
p
=
Point
(
x
:
21
,
y
:
30
)
let
s
=
String
(
describing
:
p
)
(
s
)
// Prints "(21, 30)"
The conversion of p
to a string in the assignment to s
uses the
Point
type's description
property.
Declaration
var
description
:
String
{
get
}
Declared In
CustomStringConvertible
4 inherited items hidden. (Show all)
Instance Methods
Returns a Boolean value indicating whether the value of the first argument is less than that of the second argument.
This function is the only requirement of the Comparable
protocol. The
remainder of the relational operator functions are implemented by the
standard library for any type that conforms to Comparable
.
Parameters: lhs: A value to compare. rhs: Another value to compare.
Declaration
func
<
(
lhs
:
Self
,
rhs
:
Self
) -
>
Bool
Declared In
Comparable
Returns a Boolean value indicating whether the value of the first argument is less than or equal to that of the second argument.
Parameters: lhs: A value to compare. rhs: Another value to compare.
Declaration
func
<
=(
lhs
:
Self
,
rhs
:
Self
) -
>
Bool
Declared In
Comparable
Returns a Boolean value indicating whether two values are equal.
Equality is the inverse of inequality. For any values a
and b
,
a == b
implies that a != b
is false
.
Parameters: lhs: A value to compare. rhs: Another value to compare.
Declaration
func
==(
lhs
:
Self
,
rhs
:
Self
) -
>
Bool
Declared In
Equatable
Returns a Boolean value indicating whether the value of the first argument is greater than that of the second argument.
Parameters: lhs: A value to compare. rhs: Another value to compare.
Declaration
func
>
(
lhs
:
Self
,
rhs
:
Self
) -
>
Bool
Declared In
Comparable
Returns a Boolean value indicating whether the value of the first argument is greater than or equal to that of the second argument.
Parameters: lhs: A value to compare. rhs: Another value to compare.
Declaration
func
>
=(
lhs
:
Self
,
rhs
:
Self
) -
>
Bool
Declared In
Comparable
Declaration
func
quotientAndRemainder
(
dividingBy
rhs
:
Self
) -
>
(
Self
,
Self
)
Declared In
BinaryInteger
Returns -1
if the value of self
is negative, 1
if it's positive,
0
otherwise.
Declaration
func
signum
() -
>
Self
Declared In
BinaryInteger
22 inherited items hidden. (Show all)
Default Implementations
Create an instance initialized to value
.
Declaration
init
(
integerLiteral
value
:
Self
)
Declared In
BinaryInteger
, SignedArithmetic
, Arithmetic
, ExpressibleByIntegerLiteral
Declaration
init
?
<
T
where
T
:
BinaryInteger
>
(
exactly
source
:
T
)
Declared In
SignedInteger_
, BinaryInteger
Declaration
static
var
isSigned
:
Bool
{
get
}
Declaration
static
var
max
:
Self
{
get
}
Declaration
static
var
min
:
Self
{
get
}
Declaration
var
description
:
String
{
get
}
Declaration
func
adding
(
_
rhs
:
Self
) -
>
Self
Declared In
BinaryInteger
, SignedArithmetic
, Arithmetic
Declaration
func
divided
(
by
rhs
:
Self
) -
>
Self
Declared In
BinaryInteger
, SignedArithmetic
, Arithmetic
Declaration
func
multiplied
(
by
rhs
:
Self
) -
>
Self
Declared In
BinaryInteger
, SignedArithmetic
, Arithmetic
Declaration
func
quotientAndRemainder
(
dividingBy
rhs
:
Self
) -
>
(
Self
,
Self
)
Declared In
BinaryInteger
Returns -1
if the value of self
is negative, 1
if it's positive,
0
otherwise.
Declaration
func
signum
() -
>
Self
Declared In
BinaryInteger
Declaration
func
subtracting
(
_
rhs
:
Self
) -
>
Self
Declared In
BinaryInteger
, SignedArithmetic
, Arithmetic
12 inherited items hidden. (Show all)
A type that represents an integer literal.
The standard library integer and floating-point types are all valid types for
IntegerLiteralType
.