diff options
author | Andrew Dolgov <[email protected]> | 2012-10-19 11:32:57 +0400 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2012-10-19 11:32:57 +0400 |
commit | 4ed357774aa94ad8be60ec9d257cc414462a0dc6 (patch) | |
tree | cd19a8114a952de41d196134567f21a997b406f4 /src/com/github/junrar/unsigned | |
parent | 354cef3a9c4e020aef9afeee12f846e4554ec7b7 (diff) |
switch to junrar library
Diffstat (limited to 'src/com/github/junrar/unsigned')
-rw-r--r-- | src/com/github/junrar/unsigned/UnsignedByte.java | 68 | ||||
-rw-r--r-- | src/com/github/junrar/unsigned/UnsignedInteger.java | 29 | ||||
-rw-r--r-- | src/com/github/junrar/unsigned/UnsignedLong.java | 29 | ||||
-rw-r--r-- | src/com/github/junrar/unsigned/UnsignedShort.java | 29 |
4 files changed, 155 insertions, 0 deletions
diff --git a/src/com/github/junrar/unsigned/UnsignedByte.java b/src/com/github/junrar/unsigned/UnsignedByte.java new file mode 100644 index 0000000..f59ce96 --- /dev/null +++ b/src/com/github/junrar/unsigned/UnsignedByte.java @@ -0,0 +1,68 @@ +/*
+ * Copyright (c) 2007 innoSysTec (R) GmbH, Germany. All rights reserved.
+ * Original author: Edmund Wagner
+ * Creation date: 04.06.2007
+ *
+ * Source: $HeadURL$
+ * Last changed: $LastChangedDate$
+ *
+ *
+ * the unrar licence applies to all junrar source and binary distributions
+ * you are not allowed to use this source to re-create the RAR compression algorithm
+ *
+ * Here some html entities which can be used for escaping javadoc tags:
+ * "&": "&" or "&"
+ * "<": "<" or "<"
+ * ">": ">" or ">"
+ * "@": "@"
+ */
+package com.github.junrar.unsigned;
+
+import com.github.junrar.crc.RarCRC;
+
+/**
+ * DOCUMENT ME
+ *
+ * @author $LastChangedBy$
+ * @version $LastChangedRevision$
+ */
+public class UnsignedByte {
+
+ public static byte longToByte(long unsignedByte1){
+ return (byte) (unsignedByte1&0xff);
+ }
+ public static byte intToByte(int unsignedByte1){
+ return (byte) (unsignedByte1&0xff);
+ }
+ public static byte shortToByte(short unsignedByte1){
+ return (byte) (unsignedByte1&0xff);
+ }
+
+
+ public static short add(byte unsignedByte1, byte unsignedByte2){
+ return (short) (unsignedByte1 + unsignedByte2);
+ }
+
+ public static short sub(byte unsignedByte1, byte unsignedByte2){
+
+ return (short) (unsignedByte1 - unsignedByte2);
+ }
+
+
+ public static void main(String[] args)
+ {
+ //tests unsigned (signed)
+ //add
+ System.out.println(add((byte)0xfe,(byte)0x01)); //255 (-1)
+ System.out.println(add((byte)0xff,(byte)0x01)); //0 (0)
+ System.out.println(add((byte)0x7f,(byte)0x01)); //128 (-128)
+ System.out.println(add((byte)0xff,(byte)0xff)); //254 (-2)
+
+ //sub
+ System.out.println(sub((byte)0xfe,(byte)0x01)); //253 (-3)
+ System.out.println(sub((byte)0x00,(byte)0x01)); //255 (-1)
+ System.out.println(sub((byte)0x80,(byte)0x01)); //127 (127)
+ //mul
+ System.out.println((byte)-1*(byte)-1);
+ }
+}
diff --git a/src/com/github/junrar/unsigned/UnsignedInteger.java b/src/com/github/junrar/unsigned/UnsignedInteger.java new file mode 100644 index 0000000..0f12c5c --- /dev/null +++ b/src/com/github/junrar/unsigned/UnsignedInteger.java @@ -0,0 +1,29 @@ +/*
+ * Copyright (c) 2007 innoSysTec (R) GmbH, Germany. All rights reserved.
+ * Original author: Edmund Wagner
+ * Creation date: 04.06.2007
+ *
+ * Source: $HeadURL$
+ * Last changed: $LastChangedDate$
+ *
+ *
+ * the unrar licence applies to all junrar source and binary distributions
+ * you are not allowed to use this source to re-create the RAR compression algorithm
+ *
+ * Here some html entities which can be used for escaping javadoc tags:
+ * "&": "&" or "&"
+ * "<": "<" or "<"
+ * ">": ">" or ">"
+ * "@": "@"
+ */
+package com.github.junrar.unsigned;
+
+/**
+ * DOCUMENT ME
+ *
+ * @author $LastChangedBy$
+ * @version $LastChangedRevision$
+ */
+public class UnsignedInteger {
+
+}
diff --git a/src/com/github/junrar/unsigned/UnsignedLong.java b/src/com/github/junrar/unsigned/UnsignedLong.java new file mode 100644 index 0000000..a859929 --- /dev/null +++ b/src/com/github/junrar/unsigned/UnsignedLong.java @@ -0,0 +1,29 @@ +/*
+ * Copyright (c) 2007 innoSysTec (R) GmbH, Germany. All rights reserved.
+ * Original author: Edmund Wagner
+ * Creation date: 04.06.2007
+ *
+ * Source: $HeadURL$
+ * Last changed: $LastChangedDate$
+ *
+ *
+ * the unrar licence applies to all junrar source and binary distributions
+ * you are not allowed to use this source to re-create the RAR compression algorithm
+ *
+ * Here some html entities which can be used for escaping javadoc tags:
+ * "&": "&" or "&"
+ * "<": "<" or "<"
+ * ">": ">" or ">"
+ * "@": "@"
+ */
+package com.github.junrar.unsigned;
+
+/**
+ * DOCUMENT ME
+ *
+ * @author $LastChangedBy$
+ * @version $LastChangedRevision$
+ */
+public class UnsignedLong {
+
+}
diff --git a/src/com/github/junrar/unsigned/UnsignedShort.java b/src/com/github/junrar/unsigned/UnsignedShort.java new file mode 100644 index 0000000..e9131e9 --- /dev/null +++ b/src/com/github/junrar/unsigned/UnsignedShort.java @@ -0,0 +1,29 @@ +/*
+ * Copyright (c) 2007 innoSysTec (R) GmbH, Germany. All rights reserved.
+ * Original author: Edmund Wagner
+ * Creation date: 04.06.2007
+ *
+ * Source: $HeadURL$
+ * Last changed: $LastChangedDate$
+ *
+ *
+ * the unrar licence applies to all junrar source and binary distributions
+ * you are not allowed to use this source to re-create the RAR compression algorithm
+ *
+ * Here some html entities which can be used for escaping javadoc tags:
+ * "&": "&" or "&"
+ * "<": "<" or "<"
+ * ">": ">" or ">"
+ * "@": "@"
+ */
+package com.github.junrar.unsigned;
+
+/**
+ * DOCUMENT ME
+ *
+ * @author $LastChangedBy$
+ * @version $LastChangedRevision$
+ */
+public class UnsignedShort {
+
+}
|