• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Negative numbers in Data.read (int)

 
Sean Beecroft
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • 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?
 
Alex Belisle Turcot
Ranch Hand
Posts: 516
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic