Merge pull request #61 from cloverstd/master

Fix invalid data
diff --git a/double.go b/double.go
index 73abb93..050ee25 100644
--- a/double.go
+++ b/double.go
@@ -47,7 +47,7 @@
 		if iv >= -0x80 && iv < 0x80 {
 			return encByte(b, BC_DOUBLE_BYTE, byte(iv))
 		} else if iv >= -0x8000 && iv < 0x8000 {
-			return encByte(b, BC_DOUBLE_BYTE, byte(iv>>8), byte(iv))
+			return encByte(b, BC_DOUBLE_SHORT, byte(iv>>8), byte(iv))
 		}
 
 		goto END
diff --git a/long.go b/long.go
index c482a2f..6fec2fb 100644
--- a/long.go
+++ b/long.go
@@ -41,7 +41,7 @@
 		return encByte(b, byte(int64(BC_LONG_BYTE_ZERO)+(v>>8)), byte(v))
 	} else if int64(LONG_SHORT_MIN) <= v && v <= int64(LONG_SHORT_MAX) {
 		return encByte(b, byte(int64(BC_LONG_SHORT_ZERO)+(v>>16)), byte(v>>8), byte(v))
-	} else if 0x80000000 <= v && v <= 0x7fffffff {
+	} else if -0x80000000 <= v && v <= 0x7fffffff {
 		return encByte(b, BC_LONG_INT, byte(v>>24), byte(v>>16), byte(v>>8), byte(v))
 	}