osc icon indicating copy to clipboard operation
osc copied to clipboard

Double floats doesn't work correctly

Open erikronstrom opened this issue 8 years ago • 0 comments

encode-data checks for float (using typecase), and encodes it using encode-float32. However, if a double float is passed to encode-data, it will also match the float clause and will be encoded as a single-float.

Depending on the implementation, this may give the correct result, throw an error, or silently fail with the wrong result. (That's what happened to me)

A simple fix would be to change the typecond clause in encode-data (and encode-typetags) from float to single-float. This could later be complemented by a check for double-float, calling encode-float64.

Another possible simple fix would be to coerce the value to a single-float before passing it to encode-float32.

erikronstrom avatar May 31 '17 10:05 erikronstrom