From bd91f0fb4c67c7effc4715600e53f38bf1b79e12 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 21 Feb 2014 07:57:29 +0100 Subject: Bitstream: Refine c70c730b22c847668cf475dc6f841b85297ac3ab: 'toUint32Long' -> 'toUInt32Long', add 'uint32LongtoInt' --- src/java/com/jogamp/common/util/Bitstream.java | 28 +++++++++++++++++--------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'src/java/com') diff --git a/src/java/com/jogamp/common/util/Bitstream.java b/src/java/com/jogamp/common/util/Bitstream.java index 419b356..7938c1c 100644 --- a/src/java/com/jogamp/common/util/Bitstream.java +++ b/src/java/com/jogamp/common/util/Bitstream.java @@ -1167,7 +1167,7 @@ public class Bitstream { * and swap bytes if !bigEndian. *

* In case the returned value shall be interpreted as uint32_t - * utilize {@link #toUint32Long(int)} or {@link #toUint32Int(int)} for + * utilize {@link #toUInt32Long(int)} or {@link #toUInt32Int(int)} for * an appropriate conversion. *

* @param msbFirst if true incoming stream bit order is MSB to LSB, otherwise LSB to MSB. @@ -1215,7 +1215,7 @@ public class Bitstream { * and swap bytes if !bigEndian. *

* In case the returned value shall be interpreted as uint32_t - * utilize {@link #toUint32Long(int)} or {@link #toUint32Int(int)} for + * utilize {@link #toUInt32Long(int)} or {@link #toUInt32Int(int)} for * an appropriate conversion. *

* @param bigEndian if false, swap incoming bytes to little-endian, otherwise leave them as little-endian. @@ -1306,22 +1306,30 @@ public class Bitstream { * final long l = 0xffffffffL & int32; * */ - public static final long toUint32Long(final int val) { - return 0xffffffffL & val; + public static final long toUInt32Long(final int int32) { + return 0xffffffffL & int32; } /** * Returns the reinterpreted given int32_t value - * as uint32_t if < {@link Integer#MAX_VALUE} + * as uint32_t if ≤ {@link Integer#MAX_VALUE} * as within an int storage. * Otherwise return -1. */ - public static final int toUint32Int(final int val) { - final long v = toUint32Long(val); - if( v > Integer.MAX_VALUE ) { - return -1; + public static final int toUInt32Int(final int int32) { + return uint32LongtoInt(toUInt32Long(int32)); + } + + /** + * Returns the given uint32_t value long + * value as int if ≤ {@link Integer#MAX_VALUE}. + * Otherwise return -1. + */ + public static final int uint32LongtoInt(final long uint32) { + if( Integer.MAX_VALUE >= uint32 ) { + return (int)uint32; } else { - return (int)v; + return -1; } } -- cgit v1.2.3