Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does double.MaxValue and double.MinValue mean in the following context?

Tags:

c#

What does double.MaxValue and double.MinValue mean in the following context:

double minX, minY, maxX, maxY;
minX = double.MaxValue;
minY = double.MaxValue;
maxX = double.MinValue;
maxY = double.MinValue;

for(int i = 0 ; i < HPts.BranchCount; i++){
  foreach(Point3d pt in HPts.Branch(i)){
    if(minX > pt.X){
      minX = pt.X;
    }

    if(minY > pt.Y){
      minY = pt.Y;
    }

    if(maxX < pt.X){
      maxX = pt.X;
    }

    if(maxY < pt.Y){
      maxY = pt.Y;
    }
like image 406
Arthur Mamou-Mani Avatar asked Dec 11 '25 03:12

Arthur Mamou-Mani


1 Answers

They are the maximum and minimum values you can store in a double.

This is used to determine the min/max X and Y locations. For example, by starting with minX set to the maximum allowable value for a double, the first time through the loop, minX > pt.X will be true, which will cause minX to set to the first X value. Eventually, the minimum value for X will be stored there.

like image 52
Reed Copsey Avatar answered Dec 13 '25 16:12

Reed Copsey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!