• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

stupid question

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how can I read unsigned long in java?
the db has:
4 byte numeric, total overall length in bytes of each record

I read it like this:
RecordLength = (database.readUnsignedShort() << 16) |
(database.readUnsignedShort());

But that is obviously wrong!
How can I do it?

Even if I can do it, how can one reserve a byte array [size], where size
is unsigned long? size must always be int!

S
 
Shlomo Hillel
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry, that is reading unsigned integer.
I cannot use shifts and store it in a long since shift works on int.

Can I just say i treat it as a signed number and reject record lengths above
(2**31 -1)?
S
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
4 bytes is 32 bits, and that's an int in Java. (or is that what you meant in your second post?). Anyway, I would treat it as signed, accept only positive values and note the fact in my choices document. Considering the range of positive values of a int, it makes sense to me to do that.
[ June 23, 2006: Message edited by: Barry Gaunt ]
 
Villains always have antidotes. They're funny that way. Here's an antidote disguised as a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic