-
Notifications
You must be signed in to change notification settings - Fork 7
/
int16.go
186 lines (156 loc) · 3.71 KB
/
int16.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
package ameda
import (
"math"
"strconv"
)
// Int16ToInterface converts int16 to interface.
func Int16ToInterface(v int16) interface{} {
return v
}
// Int16ToInterfacePtr converts int16 to *interface.
func Int16ToInterfacePtr(v int16) *interface{} {
r := Int16ToInterface(v)
return &r
}
// Int16ToString converts int16 to string.
func Int16ToString(v int16) string {
return strconv.FormatInt(int64(v), 10)
}
// Int16ToStringPtr converts int16 to *string.
func Int16ToStringPtr(v int16) *string {
r := Int16ToString(v)
return &r
}
// Int16ToBool converts int16 to bool.
func Int16ToBool(v int16) bool {
return v != 0
}
// Int16ToBoolPtr converts int16 to *bool.
func Int16ToBoolPtr(v int16) *bool {
r := Int16ToBool(v)
return &r
}
// Int16ToFloat32 converts int16 to float32.
func Int16ToFloat32(v int16) float32 {
return float32(v)
}
// Int16ToFloat32Ptr converts int16 to *float32.
func Int16ToFloat32Ptr(v int16) *float32 {
r := Int16ToFloat32(v)
return &r
}
// Int16ToFloat64 converts int16 to float64.
func Int16ToFloat64(v int16) float64 {
return float64(v)
}
// Int16ToFloat64Ptr converts int16 to *float64.
func Int16ToFloat64Ptr(v int16) *float64 {
r := Int16ToFloat64(v)
return &r
}
// Int16ToInt converts int16 to int.
func Int16ToInt(v int16) int {
return int(v)
}
// Int16ToIntPtr converts int16 to *int.
func Int16ToIntPtr(v int16) *int {
r := Int16ToInt(v)
return &r
}
// Int16ToInt8 converts int16 to int8.
func Int16ToInt8(v int16) (int8, error) {
if v > math.MaxInt8 || v < math.MinInt8 {
return 0, errOverflowValue
}
return int8(v), nil
}
// Int16ToInt8Ptr converts int16 to *int8.
func Int16ToInt8Ptr(v int16) (*int8, error) {
r, err := Int16ToInt8(v)
return &r, err
}
// Int16ToInt16Ptr converts int16 to *int16.
func Int16ToInt16Ptr(v int16) *int16 {
return &v
}
// Int16ToInt32 converts int16 to int32.
func Int16ToInt32(v int16) int32 {
return int32(v)
}
// Int16ToInt32Ptr converts int16 to *int32.
func Int16ToInt32Ptr(v int16) *int32 {
r := Int16ToInt32(v)
return &r
}
// Int16ToInt64 converts int16 to int64.
func Int16ToInt64(v int16) int64 {
return int64(v)
}
// Int16ToInt64Ptr converts int16 to *int64.
func Int16ToInt64Ptr(v int16) *int64 {
r := Int16ToInt64(v)
return &r
}
// Int16ToUint converts int16 to uint.
func Int16ToUint(v int16) (uint, error) {
if v < 0 {
return 0, errNegativeValue
}
return uint(v), nil
}
// Int16ToUintPtr converts int16 to *uint.
func Int16ToUintPtr(v int16) (*uint, error) {
r, err := Int16ToUint(v)
return &r, err
}
// Int16ToUint8 converts int16 to uint8.
func Int16ToUint8(v int16) (uint8, error) {
if v < 0 {
return 0, errNegativeValue
}
if v > math.MaxUint8 {
return 0, errOverflowValue
}
return uint8(v), nil
}
// Int16ToUint8Ptr converts int16 to *uint8.
func Int16ToUint8Ptr(v int16) (*uint8, error) {
r, err := Int16ToUint8(v)
return &r, err
}
// Int16ToUint16 converts int16 to uint16.
func Int16ToUint16(v int16) (uint16, error) {
if v < 0 {
return 0, errNegativeValue
}
return uint16(v), nil
}
// Int16ToUint16Ptr converts int16 to *uint16.
func Int16ToUint16Ptr(v int16) (*uint16, error) {
r, err := Int16ToUint16(v)
return &r, err
}
// Int16ToUint32 converts int16 to uint32.
func Int16ToUint32(v int16) (uint32, error) {
if v < 0 {
return 0, errNegativeValue
}
return uint32(v), nil
}
// Int16ToUint32Ptr converts int16 to *uint32.
func Int16ToUint32Ptr(v int16) (*uint32, error) {
r, err := Int16ToUint32(v)
return &r, err
}
// Int16ToUint64 converts int16 to uint64.
func Int16ToUint64(v int16) (uint64, error) {
if v < 0 {
return 0, errNegativeValue
}
return uint64(v), nil
}
// Int16ToUint64Ptr converts int16 to *uint64.
func Int16ToUint64Ptr(v int16) (*uint64, error) {
r, err := Int16ToUint64(v)
return &r, err
}