Bitwise Encoding

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jun 2006
Posts: 7,628
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 468
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: Bitwise Encoding

 
0
  #11
Jul 11th, 2009
> 0-5 : 4 bits
I wonder how you came up with 4. ;-)

@llemes4011
Coming up with your own serialization mechanism is hard; continue if you are doing this for fun but do remember that there are many other good binary serialization formats out there which can lessen your work and reduce the agony. A comparison of various serialization libraries can be found here.
Last edited by ~s.o.s~; Jul 11th, 2009 at 12:04 pm.
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 982
Reputation: JamesCherrill is just really nice JamesCherrill is just really nice JamesCherrill is just really nice JamesCherrill is just really nice JamesCherrill is just really nice 
Solved Threads: 145
JamesCherrill JamesCherrill is offline Offline
Posting Shark

Re: Bitwise Encoding

 
0
  #12
Jul 11th, 2009
Originally Posted by ~s.o.s~ View Post
> 0-5 : 4 bits
I wonder how you came up with 4. ;-)
Oh yes, thanks. I jumped straight to ( smallest n where 2^n >= 5 ), but it should be (2^(n+1) - 1) >= 5
Sorry OP, subtract 1 bit from my previous post.
J.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 207
Reputation: llemes4011 is an unknown quantity at this point 
Solved Threads: 13
llemes4011 llemes4011 is offline Offline
Posting Whiz in Training

Re: Bitwise Encoding

 
0
  #13
Jul 11th, 2009
Originally Posted by JamesCherrill View Post
ps I hope you need to store millions of these, because otherwize it's all a waste of time. A few bytes here or there don't matter today.
closer to around 40,000 >.< I was hoping that it would be a bit easier and more convenient than this for my needs >.<
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 982
Reputation: JamesCherrill is just really nice JamesCherrill is just really nice JamesCherrill is just really nice JamesCherrill is just really nice JamesCherrill is just really nice 
Solved Threads: 145
JamesCherrill JamesCherrill is offline Offline
Posting Shark

Re: Bitwise Encoding

 
0
  #14
Jul 12th, 2009
Well, I would definitely say that for 40,000 it would be worth using byte and short (as per my previous post), but not worth trying to pack the bits any tighter.
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,628
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 468
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: Bitwise Encoding

 
0
  #15
Jul 12th, 2009
> closer to around 40,000

40,000 is nothing, unless you have some specifications which you would need to meet and you have *confirmed* that doing things your way is much faster than the other simpler approaches.

IMO just go with the normal way of doing things i.e. writing data as comma separated values. If you are feeling adventurous, rather screw around with an embeddable database than get involved with all the bit-fiddling. Optimize when needed and that too after profiling; premature optimization is the root of all evil.
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 830
Reputation: wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all 
Solved Threads: 94
wildgoose's Avatar
wildgoose wildgoose is offline Offline
Practically a Posting Shark

Re: Bitwise Encoding

 
0
  #16
Jul 12th, 2009
field1(int) range = 0 to 5 {3}
field2(float) range = 0.00 to 30.00 (need 2 sig-figs) {5+7=12}
field3(float) range = 0.00 to 30.00 (need 2 sig-figs) {5+7=12}
field4(int) range = 0 to 100 {3}

So 30 bits total. 32-bit integer so 2 spare bits. What fields should those two bits be given to for future expansion?

so 32/192 compaction ratio.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 982
Reputation: JamesCherrill is just really nice JamesCherrill is just really nice JamesCherrill is just really nice JamesCherrill is just really nice JamesCherrill is just really nice 
Solved Threads: 145
JamesCherrill JamesCherrill is offline Offline
Posting Shark

Re: Bitwise Encoding

 
0
  #17
Jul 12th, 2009
Hey! Now it's my turn!

> 0-100 : 3 bits
I wonder how you came up with 3. ;-)


Anyway I agree with sos. Unless you need to store this data on punched cards, the odd few 10k bytes here or there is pretty much irrelevant.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 207
Reputation: llemes4011 is an unknown quantity at this point 
Solved Threads: 13
llemes4011 llemes4011 is offline Offline
Posting Whiz in Training

Re: Bitwise Encoding

 
1
  #18
Jul 12th, 2009
Ok, thanks for all the help you guys, this stuff is way over my head anyways =P Maybe I'll understand it some day, lol, for now im going to stick with just writing the values to the file.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC