-
Notifications
You must be signed in to change notification settings - Fork 0
/
number_float32.go
54 lines (50 loc) · 905 Bytes
/
number_float32.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
package pjn
func Float32(value float32) Value {
if value == 0 {
return Zero
} else {
return func(buf *Buffer) (err error) {
buf.AppendFloat32(value)
return nil
}
}
}
func NullableFloat32(ref *float32) Value {
if ref == nil {
return Null
} else {
return Float32(*ref)
}
}
func BindFloat32(ref *float32) Value {
if ref == nil {
return produceError(ErrNilReference)
} else {
return func(buf *Buffer) error {
if *ref == 0 {
buf.AppendByte(valueNumberZero)
} else {
buf.AppendFloat32(*ref)
}
return nil
}
}
}
func BindNullableFloat32(ref **float32) Value {
if ref == nil {
return produceError(ErrNilReference)
} else {
return func(buf *Buffer) error {
if *ref == nil {
buf.AppendBytes(valueNull)
} else {
if **ref == 0 {
buf.AppendByte(valueNumberZero)
} else {
buf.AppendFloat32(**ref)
}
}
return nil
}
}
}