Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #155 from rossipedia/smalldec-fix
when sending decimals as UInt's, Math.round the value to prevent IEEE 754 floating point errors
  • Loading branch information
patriksimek committed Jun 15, 2014
2 parents 223ef30 + 39a2b77 commit cb3aebb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/data-type.coffee
Expand Up @@ -224,7 +224,8 @@ TYPE =
if parameter.precision <= 9 if parameter.precision <= 9
buffer.writeUInt8 5 buffer.writeUInt8 5
buffer.writeUInt8 sign buffer.writeUInt8 sign
buffer.writeUInt32LE value # Round to preven IEEE 754 floating point errors
buffer.writeUInt32LE Math.round(value)
else if parameter.precision <= 19 else if parameter.precision <= 19
buffer.writeUInt8 9 buffer.writeUInt8 9
buffer.writeUInt8 sign buffer.writeUInt8 sign
Expand Down

0 comments on commit cb3aebb

Please sign in to comment.