Skip to content
Tcl Source Code View Ticket
Login

View Ticket

sqrt(-1) gives -NaN

Closed / Fixed1541274fffffffffffffffffffffffffffffffffCreated 20 years agoUpdated 20 years ago
Descriptionplain2006-08-16 12:53:42
 % expr sqrt(-1)
-NaN

Does this have a reason in the IEEE standard?
Richard Suchenwirth
dgpplain2006-08-16 22:04:08
Logged In: YES 
user_id=80530



[tcl::mathfunc::sqrt] returns
whatever the libm sqrt() C
function does.  On Solaris 9:

% tcl::mathfunc::sqrt -1    
NaN(7ffffffffffff)

Does that answer the Q?
sf-robotplain2006-08-31 09:20:34
Logged In: YES 
user_id=1312539

This Tracker item was closed automatically by the system. It was
previously set to a Pending status, and the original submitter
did not respond within 14 days (the time period specified by
the administrator of this Tracker).
dgpplain2006-09-01 03:12:22
Logged In: YES 
user_id=80530


There is a real bug here:

% set x -1
-1
% expr {sqrt($x)}
domain error: argument not in valid range
% expr {sqrt(-1)}
NaN(7ffffffffffff)
dgpplain2006-09-01 03:42:13
Logged In: YES 
user_id=80530

fix committed
Log in (anonymous is fine) to add a comment.