943,892 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 1287
  • Java RSS
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Jul 11th, 2009
0

Re: Bitwise Encoding

> 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.
Super Moderator
Featured Poster
Reputation Points: 3233
Solved Threads: 719
Failure as a human
~s.o.s~ is offline Offline
8,871 posts
since Jun 2006
Jul 11th, 2009
0

Re: Bitwise Encoding

Click to Expand / Collapse  Quote originally posted by ~s.o.s~ ...
> 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.
Featured Poster
Reputation Points: 1924
Solved Threads: 951
Posting Expert
JamesCherrill is offline Offline
5,788 posts
since Apr 2008
Jul 11th, 2009
0

Re: Bitwise Encoding

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 >.<
Reputation Points: 41
Solved Threads: 13
Posting Whiz in Training
llemes4011 is offline Offline
224 posts
since Aug 2008
Jul 12th, 2009
0

Re: Bitwise Encoding

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.
Featured Poster
Reputation Points: 1924
Solved Threads: 951
Posting Expert
JamesCherrill is offline Offline
5,788 posts
since Apr 2008
Jul 12th, 2009
0

Re: Bitwise Encoding

> 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.
Super Moderator
Featured Poster
Reputation Points: 3233
Solved Threads: 719
Failure as a human
~s.o.s~ is offline Offline
8,871 posts
since Jun 2006
Jul 12th, 2009
0

Re: Bitwise Encoding

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.
Reputation Points: 546
Solved Threads: 99
Practically a Posting Shark
wildgoose is offline Offline
891 posts
since Jun 2009
Jul 12th, 2009
0

Re: Bitwise Encoding

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.
Featured Poster
Reputation Points: 1924
Solved Threads: 951
Posting Expert
JamesCherrill is offline Offline
5,788 posts
since Apr 2008
Jul 12th, 2009
1

Re: Bitwise Encoding

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.
Reputation Points: 41
Solved Threads: 13
Posting Whiz in Training
llemes4011 is offline Offline
224 posts
since Aug 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: repaint won't call paintComponent(Graphics )
Next Thread in Java Forum Timeline: illegal start of expression





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC