• Post Reply Bookmark Topic Watch Topic
  • New Topic

Binary read max and min  RSS feed

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I am reading a Binary .dat file I have everything working properly. Finding characters, sum of integers, sum of doubles, averages... the only thing I can not get it to read is the max and min o the integers and the doubles. I have tried MAX_VALUE and MaxValue. Here is my code.
 
Sheriff
Posts: 4289
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't you have to do something like:
 
Slynn Garrett
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nope it changes all the calculations to wrong integers sums
 
Knute Snortum
Sheriff
Posts: 4289
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How so? This code:

is equivalent to your code:

It just puts a variable in between reading the int and summing it. You need that variable to test for the max int.
 
Slynn Garrett
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is the placement of
that is throwing it off. Thanks
 
Knute Snortum
Sheriff
Posts: 4289
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Again, how so? The only variable that changes value is maxInt, which you didn't have before.
 
Saloon Keeper
Posts: 7993
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not related to your issue, but why do you have two nested while loops?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!