Skip to content
This repository was archived by the owner on Dec 4, 2023. It is now read-only.

Commit c402435

Browse files
authored
Merge pull request #52 from buddy-sandidge/master
Format floats to allow for very large/small values
2 parents 0058bbf + eb11637 commit c402435

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

query_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,30 @@ func TestKeys(t *testing.T) {
159159
IfExists().toCmd(),
160160
Expected: "FSET agent 47 XX cash 100500",
161161
},
162+
{
163+
Cmd: keys.FSet("agent", "47").
164+
Field("id", 123456789012345680).
165+
IfExists().toCmd(),
166+
Expected: "FSET agent 47 XX id 123456789012345680",
167+
},
168+
{
169+
Cmd: keys.FSet("agent", "47").
170+
Field("id", -123456789012345680).
171+
IfExists().toCmd(),
172+
Expected: "FSET agent 47 XX id -123456789012345680",
173+
},
174+
{
175+
Cmd: keys.FSet("agent", "47").
176+
Field("small", 0.00000000012345678901234568).
177+
IfExists().toCmd(),
178+
Expected: "FSET agent 47 XX small 0.00000000012345678901234568",
179+
},
180+
{
181+
Cmd: keys.FSet("agent", "47").
182+
Field("small", -0.00000000012345678901234568).
183+
IfExists().toCmd(),
184+
Expected: "FSET agent 47 XX small -0.00000000012345678901234568",
185+
},
162186
{
163187
Cmd: keys.JSet("foo", "bar", "some.field", "some-value").Raw().toCmd(),
164188
Expected: "JSET foo bar some.field some-value RAW",

utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func (c cmd) String() string {
2525
}
2626

2727
func floatString(val float64) string {
28-
return strconv.FormatFloat(val, 'g', 10, 64)
28+
return strconv.FormatFloat(val, 'f', -1, 64)
2929
}
3030

3131
func rawEventHandler(handler func(*GeofenceEvent)) func([]byte) error {

0 commit comments

Comments
 (0)