[Dspatial-develop] Re: access violation - again ???
Status: Alpha
Brought to you by:
pvanlaake
From: Patrick V. L. <van...@it...> - 2004-08-19 14:11:15
|
Arioch /BDV/ <the_Arioch <at> nm.ru> writes: > For all integer-flavored Histo's thelast line looks like > > scale := FBins / (Max - Min + 1); > > But for float - there is no that '+1' - what to do ? > Hi Arioch, For float types there is no real equivalent. The problem arises when there is a float value *exactly* equal to FMax. In that case the statement: Inc(FHisto[Floor((dp^ - FMin) * scale)]); tries to update FHisto[Length(FHisto)], which obviously does not exist. The problem is that the math dictates that FMax will fall outside of the range, i.e. [FMin, FMax>, which is not very elegant. The solution would be to add a test to see if the data value equals FMax (i.e. if dp^ = FMax then Inc(FHisto [FBins-1]) else ...), but this adds to the processing time. Alternatively (what I typically do), pass a max value to the constructor that is slightly larger than the maximum value (i.e. multiply by 1.0000000000001). Cheers, Patrick |