separate ( Generic_Elementary_Functions ) function Cot( X : Float_Type ) return Float_Type is -- On input, X is a floating-point value in Float_Type; -- On output, the value of cot(X) (the cotangent of X) is returned. Y, R1, R2, Sign_Y, Z, U, V : Common_Float; I_Flag, SC_Flag : Quadrant_Flag; Large_Threshold : constant Common_Float := Common_Float(Radix)**(Float_Type'Machine_Mantissa/2); Two_Pi : constant Common_Float := 6.28318_53071_79586_47692_52867_66559_00576_83943_38798_75016; begin -- Argument reduction by KP_Pi2Rd if ( X = 0.0 ) then raise Constraint_Error; end if; Y := Common_Float( X ); if ( abs(Y) > Large_Threshold ) then Y := Y rem Two_Pi; end if; if (Y > 0.0) then Sign_Y := 1.0; else Sign_Y := -1.0; Y := abs(Y); end if; KP_Pi2Rd( Y, R1, R2, I_Flag ); SC_Flag := I_Flag mod 2; U := KF_Sin(R1,R2); V := KF_Cos(R1,R2); if (SC_Flag = 1) then Z := -U / V; else Z := V / U; end if; return( Float_Type( Sign_Y * Z ) ); end Cot;