ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1103. Pencils and Circles

Can a square of an integer number be negative?
Posted by Sergey Baskakov, Raphail and Denis 6 Apr 2005 01:02
My solution resulted in Crash {FLT_INVALID_OPERATION} several times, before I understood, that the square of an integer number can be negative!

Oh! What a stupid mistake!-)

The crash mentioned above was caused by the following function in my source code:

function Dist( const p1, p2: Point ): extended;
begin
    Result := sqrt( sqr(p2.x-p1.x) + sqr(p2.y-p1.y) );
end;

I couldn't even imagine, that sqr() function can produce negative results!

So, If you get Crash on test #6, just use extended (^:
Re: Can a square of an integer number be negative?
Posted by Edric Mao 12 Aug 2010 17:32
Holy crap
I can't believe either!!
Thanks