On Monday 24 October 2011 18:28:46 Andrew Dalke wrote:
> char[] hexArray =
> {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
>
>
> public String toString() {
> for (int i=0; i<byteLength; i++) {
> b = print[i];
> buffer.setCharAt(i*2, hexArray[b >> 4]);
> buffer.setCharAt(i*2, hexArray[b & 0x0f]);
> }
> return buffer.toString();
> }
Java Bit-Shifting with bytes is a bit strange. The expression b>>4
does not always shift zeros into the leftmost position (the value
depends on the sign of the byte). Surprisingly, the unsigned shift
operator b>>>4 does not work either for bytes, since Java casts to an
int in an unexpected way before doing the shift. However, using (b >>
4) & 0x0F should work.
I have also written a (preliminary) FPS implementation (reading and
writing) in Java some time ago. Unfortunately, the code is not well
optimized and not tested to fully meet the specification:
<http://ls11-www.cs.tu-
dortmund.de/people/kriege/FPSTreeIndexing/src/FPSConverter.java>
Nils
------------------------------------------------------------------------------
The demand for IT networking professionals continues to grow, and the
demand for specialized networking skills is growing even more rapidly.
Take a complimentary Learning@Cisco Self-Assessment and learn
about Cisco certifications, training, and career opportunities.
http://p.sf.net/sfu/cisco-dev2dev
_______________________________________________
Cdk-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cdk-user