• Post Reply Bookmark Topic Watch Topic
  • New Topic

bit[] from byte  RSS feed

 
Anton Pechsherov
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need vector(String , or somthink else) of bits from byte, how i can do it?
I tried make self class witch do it, but i think java have this method . Please help me.
 
Anton Pechsherov
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I fill nobody doesnt'n know it ...
Does it so hard?
Question closed...i made it myself.
 
Gamini Sirisena
Ranch Hand
Posts: 378
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 help..
 
Gamini Sirisena
Ranch Hand
Posts: 378
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You solved it yourself? That's great!

Please tell us how you did it.
 
Rob Spoor
Sheriff
Posts: 21131
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Gamini Sirisena:
Even boolean uses up one byte in Java.

Not necessarily. The JLS does not require booleans to have a specific size, unless you're serializing. It's very well allowed to use a single byte for up to 8 booleans in memory.

That said, java.util.BitSet is just what Anton needed:
 
Gamini Sirisena
Ranch Hand
Posts: 378
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hmm, are there bit addressable architectures out there?
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Expecting an answer within 60 minutes is rather ambitious... but since solving the problem apparently took less time than that, so much the better :-)
 
Anton Pechsherov
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

At first i thought that , need to make simple class (byte)(mod and div)2), but java has own instrument to get bits..
[ September 28, 2008: Message edited by: Anton Pechsherov ]
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!