Skip to content
Browse files

when sending decimals as UInt's, Math.round the value to prevent IEEE…

… 754 floating point errors
  • Loading branch information...
1 parent 84d7b00 commit 39a2b772e903f9336cfe42ab19ca8499574b1d62 @rossipedia rossipedia committed Jun 15, 2014
Showing with 2 additions and 1 deletion.
  1. +2 −1 src/data-type.coffee
View
3 src/data-type.coffee
@@ -224,7 +224,8 @@ TYPE =
if parameter.precision <= 9
buffer.writeUInt8 5
buffer.writeUInt8 sign
- buffer.writeUInt32LE value
+ # Round to preven IEEE 754 floating point errors
+ buffer.writeUInt32LE Math.round(value)
else if parameter.precision <= 19
buffer.writeUInt8 9
buffer.writeUInt8 sign

0 comments on commit 39a2b77

Please sign in to comment.
Something went wrong with that request. Please try again.