• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Negative numbers in Data.read (int)

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The maximum number of possible records is the maximum value of integer. 2147483647 +
minimum number of possible records is the minimum value of integer, which is -2147483647

It is confusing when you try to figure out a way of indexing a record against a database.

I am trying to decide something....... Does anyone have any ideas about this issue?
 
Ranch Hand
Posts: 516
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I start my records at 0 and documented the maximum number of records my database implementation can handle.

You could also start at the minimum (negative) value and go up to the max.

[LIST]
[*]Starting from 0.. Reading record 3 => jump 0,1,2.
[*]Starting from -MIN.. Reading record (-MIN+3) => jump (-MIN),(-MIN+1),(-MIN+2).

Regards,
Alex
 
Alex Belisle Turcot
Ranch Hand
Posts: 516
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

to add to my previous response..

I use a HashMap to store the records and keys are the records number, so it could be any "unique" number, so my logic with negative or starting from 0 would actually always be "get this record with this key".

The key point is to document your choice/limitation.

Regards,
Alex
 
Sean Beecroft
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is what I did too. It may seem like a stupid question or obvious to some, but as I flushed the application out I thought of all the potential edge cases that might occur in Data. That was one of them.

I documented the choice.

Thanks for the input
 
reply
    Bookmark Topic Watch Topic
  • New Topic