2

Is there a java library implementing the standard data types as they are available in C?

In Java everything is signed, so using byte to store uint8_t comes with some problems, for example:

byte test = (byte) 0xf3;
System.out.println("test = " + test);

prints

test = -13

instead of

test = 243

I think of something like this:

UInt8 test = new UInt8(0xf3);
System.out.println("test = " + test.toInt());
Mat
  • 202,337
  • 40
  • 393
  • 406
Ethan Leroy
  • 15,804
  • 9
  • 41
  • 63

2 Answers2

2

there's a workaround, try System.out.println("test = " + (0xff & test)); you'll get 243

Evgeniy Dorofeev
  • 133,369
  • 30
  • 199
  • 275
0

I don't think there is any good library that implements C/POSIX standard datatypes.

Recently I had to use predefined POSIX constants such as S_IREAD or S_IFDIR in a Java program and I had to create my own constants list class...

As @Evgeniy Dorofeev suggested, try to find workarounds :)

superbob
  • 1,628
  • 13
  • 24