
Hi,
Could someone clarify, what does this code accomplish? This is taken from the source code
int max = int.MinValue, min = int.MaxValue;
for (int k = 0; k < distance.Length; ++k)
{
if (distance[k] > max) max = distance[k];
if (distance[k] < min && distance[k] != 1) min = distance[k];
}
if distance[k] is between int.MinValue and int.MaxValues, then min=max?
Thanks.


Oct 7, 2012 at 1:57 PM
Edited Oct 7, 2012 at 1:59 PM

Hello ikel,
This part looks for the maximum and minimum distance. I have initilized the variables max and min with a value that force the change in the first iteration. Another option could be
int max = distance[0], min = distance[0];
for (int k = 1; k < distance.Length; ++k)
{
if (distance[k] > max) max = distance[k];
if (distance[k] < min && distance[k] != 1) min = distance[k];
}
I hope it clarifies your doubt.



Hi frantracer,
It clarifies the issue. I like your original implementation.
Thank you.
Regards,
Ikel
From: [email removed]
Sent: Sunday, October 07, 2012 11:57 PM
To: [email removed]
Subject: Re: Help is needed to understand int.maxValue [frantracerKinectFT:397484]
From: frantracer
Hello ikel,
This part looks for the maximum and minimum distance. I have initilized the variables max and min with a value that force the change in the first iteration. Another option could be
int max = distance[0], min = distance[0];
for (int k = 1; k < distance.Length; ++k)
{
if (distance[k] > max) max = distance[k];
if (distance[k] < min && distance[k] != 1) min = distance[k];
}
I hope it clarifies your doubt.

