bit « byte « Java Data Type Q&A





1. java bit manipulation    stackoverflow.com

byte x = -1;
for(int i = 0; i < 8; i++)
{
    x = (byte) (x >>> 1);
    System.out.println("X: " + x);
}
As I understand it, java ...

2. convert a two Byte bit mask into a EnumSet    stackoverflow.com

I am reading a binary file that has values stored in bit masks, both 1 Byte bit masks and 2 Byte bit masks. Each bit in the masks act as a ...

3. Java: Why does a 512-bit RSA KeyPairGenerator return 65 byte keys?    stackoverflow.com

this is somewhat a newbie question probably. I'm generating keypairs with Java:

KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
SecureRandom random = SecureRandom.getInstance("SHA1PRNG", "SUN");
keyGen.initialize(512, random);

KeyPair keyPair = keyGen.genKeyPair();

RSAPrivateKey privateKey = (RSAPrivateKey)keyPair.getPrivate();
Now I always thought that privateKey.getModulus() ...

4. How to set bit values which are not divided on byte boundary    stackoverflow.com

I have a header field of 2 bytes where first four bits are packet type and other 12 bits are for length. but i don't know how to store this values ...

5. Issues with reversing bit shifts that roll over the maximum byte size?    stackoverflow.com

I'm trying to do a simple caesarian shift on a binary string, and it needs to be reversable. I've done this with this method..

public static String cShift(String ptxt, int addFactor)
 ...

6. bit manipulation in java    stackoverflow.com

I have a fragment of bytes in a byte[]. The total size of the array is 4 and I want to convert this into a positive long number. For example if ...

7. How can I invert bits of an unsigned byte in Java?    stackoverflow.com

I am trying to write a decoder for a very simple type of encryption. Numbers from 0-255 are entered via Scanner, the bits are inverted, and then converted to a character ...

8. How to convert a byte into bits?    stackoverflow.com

I have one array of bytes. I want to access each of the bytes and want its equivalent binary value(of 8 bits) so as to carry out next operations on it. ...

9. WebSocket key1+key2+8_byte_data != 16 bytes (128 bits)?    stackoverflow.com

I'm trying to build a websocket server in Java, but I'm having difficulty... the specification of websockets say that you have to concatenate the numbers from key1 and key2 then concatenate ...





10. Set specific bit in byte    stackoverflow.com

I'm trying to set bits in Java byte variable. It does provide propper methods like .setBit(i). Does anybody know how I can realize this? I can iterate bit-wise through a given byte:

if( ...

11. Change bits value in Byte    stackoverflow.com

I have some data in field type Byte ( I save eight inputs in Byte, every bit is one input ). How to change just one input in that field ( Byte) ...

12. How Byte data be converted to bits and again converted back to Byte?    stackoverflow.com

1 Byte = 8 bits. I have to work on 120 bits. So 15 Byte. This 120 bits will be in the form of 00010101000000............ So each 8 bit that is 00010101 is ...

13. How to remove (f) bits from overflow byte in java    stackoverflow.com

How to get only b0 from byte value ffffffb0. I try (0xff & ffffffb0) but I still get the same results. Some solution.

14. Why does right shift (>>) bit operation over byte give strange result?    stackoverflow.com

There is a byte [01100111] and I've to break it in such way [0|11|00111] so after moving parts of this byte into different bytes I'll get:

[00000000] => 0 (in decimal)
[00000011] => 3 ...

15. How to declare fixed size 48 bit data type in Java?    stackoverflow.com

I need to declare a fixed size data type with maximum 48 bits in Java. Can anybody help me with that? I tried using a Byte array, but since it is ...

16. How to make 1 byte from 8 bit samples in java or c?    stackoverflow.com

I have 8 bit samples with random values (called headers) and I have commands with hexadecimal values, see bellow:

[8 bit][command]
 \      |
  \   ...





17. What is the most efficient way in Java to pack bits into byte[] and read it back?    stackoverflow.com

I currently use these two functions to pack and read bits in a byte array. Wondering if anybody has any better ideas or faster ways to do it? Edited the program ...

18. Converting a String representation of bits to a byte    stackoverflow.com

I'm just beginning to learn about file compression and I've run into a bit of a roadblock. I have an application that will encode a string such as "program" as a ...

19. To swap the byte in long using bit    coderanch.com

20. BITS, Bytes, Hex, Octal    coderanch.com

21. Reading bytes and bits    coderanch.com

22. bit[] from byte    coderanch.com

As far as I know you cannot have anything like bit[]. The byte is the smallest data type you have. Even boolean uses up one byte in Java. Java has bit operations and may be that could accomplish what you are trying to do. If you give more and as much information as you can ranchers here will be able to ...

23. Best approach for handling bits of a byte    coderanch.com

I am reading data from a serial device and several of the fields are alarm fields where the bits on or off indicate the alarm is on or off at that moment. Alarm Bit Low outside temp alarm 0 High outside temp alarm 1 Wind speed alarm 2 10 min avg speed alarm 3 Low dewpoint alarm 4 High dewpoint alarm ...

24. Bits n Bytes    coderanch.com

Hey Folks. I am attempting to set bits within a specific byte and then send the byte on its way. The device that I am communicating with doesn't seem to recognize changes in the bits; it acts exactly the same way as if the byte I am sending is a 1 or a 0. I am using the bitwise OR and ...

25. Bits & Bytes    coderanch.com

Hi I try to understand how an a Byte/Short/Integer/Long is represented by a binary. Normally 1111 1111 1111 1111 1111 1111 1111 1100 stands for 4294967292, but in Java it's -4. Because of something called two's complement, right? How can I calculate this? Do I have to do 1111 1111 1111 1111 1111 1111 1111 1100 - binary of 1 and ...

26. Converting a byte to individual bits    java-forums.org

Dear community, I have been asked to implement a CRC from scratch. From what I have learnt the CRC basically works by performing a series of XOR operations on the ploynomial, bit by bit. I believe that in order to work the method I need to convert a byte into bits first. The CRC is none of my concern, I know ...

27. Addition in Java bits, bytes and shift    forums.oracle.com

28. How to convert a Byte into Bits    forums.oracle.com

29. manipulate bits in byte    forums.oracle.com

30. Bits,Bytes,Streams?    forums.oracle.com

Hey all, I've been a bit confused (no pun intended) about the notion of reading and writing bits and bytes to files. We're working on a huffman compression program which from what I understand works on the premise that it will replace all the characters with a coding of bits that is found by figuring out how often the character occurs ...

31. Bits and Bytes    forums.oracle.com

32. bit byte question    forums.oracle.com

It doesn't matter, even if the bits in a byte were upside down. There are eight bits in a byte, that's all you need to know; i.e. there is no imposed 'position' of bits at all. Suppose we all wrote numbers from right to left: 321 would mean hundredtwentythree to all of us. kind regards, Jos

33. Read bits[] from a byte    forums.oracle.com

Hi morgair. I tend to create "my" Java API in order to understand this device. The only thing I know is the streaming data format provided by the device manufacturer. For example: The fourth byte from total received byte buffer represents the: Data Format with description 0x02 (to be honest I did not understand what it should mean), Data Type= 8 ...

34. reading a 10 bits of a 2 bytes....    forums.oracle.com

Hi I got this problem, I'm receiving a bytestream and I have to figure out what value are returned. I have sample code in C++, but doesn't seem to make sense when I log the result in Java. So if somebody can help me with this one. C++ code: BYTE Byte[40]; Byte[0]=0; for(;;) { TimePakIn=GetTickCount(); ReadFile (hCom, Byte, 1, &dwBytesTransferred, 0); ...

35. bits n bytes    forums.oracle.com

From the API for valueOf Returns a Byte instance representing the specified byte value. If a new Byte instance is not required, this method should generally be used in preference to the constructor Byte(byte), as this method is likely to yield significantly better space and time performance by caching frequently requested values. <./quote>

36. bit[] to byte[] and back    forums.oracle.com

37. How to carry out byte to bits?    forums.oracle.com