Re: How to indicate byte-format in numeral constants
J=FCrgen Gerstacker wrote On 12/18/06 04:53,:
Hello,
very frequently I have to use Byte-constants, numbers in the range 0x80=
- 0x7f. If I don't cast such a constant with '(byte)' I get an error
like:
write_4bytes(byte,byte) in ser.yyy_ser cannot be applied to (int,byte)
cls.write_4bytes(0xf0,(byte)0x4d); //sw
C has several suffixes like 0b, 10u, 7l to indicate byte-constants, or
unsigned constants, or long constants, .... Is such possible also with
java, or is casting with '(byte)' obligatory?
C has 'l' to denote a long constant, and so does Java.
C has 'u' to denote an unsigned constant, but since Java's
only unsigned integer type is 'char' Java doesn't use 'u'.
C does not use a 'b' suffix, and neither does Java.
You could solve your problem by writing casts in each
call. A possibly more convenient approach might be to change
the write_4bytes method to take two int arguments instead of
two bytes, with the (documented) understanding that only the
low-order byte of each int is written. See, for example, the
write(int) method of java.io.OutputStream for precedent.
--
Eric.Sosman@sun.com