>If you declare Last_GS as int64, you should not get the warning.

I declared both Last_GS and G_End as int64, leaving Max_Program_to_Display as a 
word and still get the warning.  If I also make Max_Program_to_Display int64, 
then I do not get the warning.   I believe it's due to the -1. If 
Max_Program_To_Display was a 0 then subtracting 1 from it would be out of range 
from a word for that portion of the formula, even though the end result would 
fit in Last_GS

>Last_GS:=G_End-(longint(Max_Program_To_Display)-1);
This aso fixes the warning if I leave all my variables alone.  If I understand 
this correctly in this case longint() is a function that returns a longint 
variable to be used in the calculation, so when it does the -1 it's ok it that 
part of the formula ends up being negative.

So now my question is, which is the best method to use?  My thinking with 
declaring Max_Program_To_Display as a word was that this value has no meaning 
if it is negative, and actually a word is way too generous for this value, a 
byte would be overkill.  Last_GS and G_End could be very large, so that's the 
reason for the longint.  So I can either declare Max_Program_to_Dispalay as a 
longint and use more memory for that variable, or use a longint() function in 
my formula and that calculation would have one more function to process, or 
turn off the warnings but then there could be a condition where I could get an 
out of range result during the computation even though the final result would 
have been in range.. but this happens sometimes so I would rather fix it to 
never happen.

I'm from the old school way of thinking that programs should use as little 
memory and be as efficient as possible, after all some of my computers only had 
4K of RAM,  but I'm wondering if that has become irrelevant with modern 
computers.
Does it really matter anymore how much memory I use up with variables?   Maybe 
I should just declare all whole number variables as int64 and all decimal 
numbers as Double and not worry about how much memory I use, after all I have 
gigabytes of ram to use now, not 64K blocks of ram that each turbo pascal unit 
had to fit into.  Even if I had 1 million int64 variables and 1 million double 
variables, that would only end up being 18MB of memory, not much of dent in 
1GB... and most pcs have more than 1GB of RAM.  

I suppose it would take longer to process all formulas with int64 and double 
variables compared to using smaller variables, but then again processor speed 
is also very fast now, so should I even be bothered with it?

I'm curious what the general method is now?   

James


_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to