delphi - Comparison of negative and positive numbers -


i have comparison function getting way complex i'm trying do. receive double can positive or negative. storing global variable needs smallest value. in terms of comparison, means smallest positive number, or if incoming values negative, smallest global value negative.

my code turning bunch of if statements handling if incoming positive or negative. need compare differently if current global value positive or negative.

is there better way compare 2 numbers , lowest of two?

partial example code:

if nestobject.rectangularscrap <> 0 begin     if nestobject.rectangularscrap > 0 begin       //positive rect scrap       if(nestobject.rectangularscrap < gbestrect) begin         gbestrect := nestobject.rectangularscrap;       end;       if(nestobject.rectangularscrap > gworstrect) begin         gworstrect := nestobject.rectangularscrap;       end;     end     else begin       //negative rect scrap       if gbestrect > 0 begin         //global value positive         gbestrect := nestobject.rectangularscrap;       end       else begin         //global value negative, change both values postive compare         if((-1*nestobject.rectangularscrap) < (-1*gbestrect)) begin           gbestrect := nestobject.rectangularscrap;         end;         if((-1*nestobject.rectangularscrap) > gworstrect) begin           gworstrect := nestobject.rectangularscrap;         end;       end;     end;   end;  

have tried min function ?

http://www.delphibasics.co.uk/rtl.asp?name=min


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -