I use Delphi 5 for occasional programming chores, including a nice business app for my electronics biz. I've done some graphics, database, and general other stuff with it over many years.
Today, I'm making a simulation in which I want to move pixels around based on some physics, the details are not important on the app, but I've been searching all morning and some of yesterday to figure out how to use the Square Root, and Square functions without getting bizarre answers. By inspecting a simple calculation which is assigned to an Extended variable type "vector_length", I get something like this when calculating (the numbers are fixed, but same result with any float type representing those numbers):
vector_length := Sqrt(Sqr(3.4) + Sqr(3))
which gives me, theoretically, about 4.53. Reasonable enough using a calculator.
Delphi's debugger shows me something like this:
2.9134839203548e-322
Which is obviously a floating point representation that makes no sense.
The code does not work like expected, so I can only think that the math is wrong or I'm doing something wrong in expecting the functions to give me something along the lines of a reasonable result??
Thanks for any input.
Hypot
function.) – Andreas Rejbrand