E
emma middlebrook
Hi
Here's a couple of functions that could do with a bit of a review! The
intent is pretty obvious but am worried about (whether I can do
anything about):
- the overflow in the multiplication steps
- the consequences of the cast to int in the 2nd function
- incorrect typing e.g. 2nd function returning an int - maybe should
be a double as well??
static double Distance(PointF pointOne, PointF pointTwo)
{
double dx = pointOne.X - pointTwo.X;
double dy = pointOne.Y - pointTwo.Y;
return Math.Sqrt(dx*dx + dy*dy);
}
static int Distance(Point pointOne, Point pointTwo)
{
double dx = pointOne.X - pointTwo.X;
double dy = pointOne.Y - pointTwo.Y;
return (int)Math.Sqrt(dx*dx + dy*dy);
}
Any help appreciated!
Emma Middlebrook
(e-mail address removed)
Here's a couple of functions that could do with a bit of a review! The
intent is pretty obvious but am worried about (whether I can do
anything about):
- the overflow in the multiplication steps
- the consequences of the cast to int in the 2nd function
- incorrect typing e.g. 2nd function returning an int - maybe should
be a double as well??
static double Distance(PointF pointOne, PointF pointTwo)
{
double dx = pointOne.X - pointTwo.X;
double dy = pointOne.Y - pointTwo.Y;
return Math.Sqrt(dx*dx + dy*dy);
}
static int Distance(Point pointOne, Point pointTwo)
{
double dx = pointOne.X - pointTwo.X;
double dy = pointOne.Y - pointTwo.Y;
return (int)Math.Sqrt(dx*dx + dy*dy);
}
Any help appreciated!
Emma Middlebrook
(e-mail address removed)