separate ( Generic_Elementary_Functions ) function KF_TanCy( X, Cycle : Float_Type ) return Float_Type is -- On input, X is a floating-point value in Float_Type; Cycle is a -- user specificed period. -- On output, the value of tan(X*2pi/Cycle) is returned. R, Y, Sign_Y, Z, User_Period, P_Lead, P_Trail, K : Common_Float; U, V : Common_Float; Zero : Common_Float := 0.0; I_Flag, SC_Flag : Quadrant_Flag; Two_Pi : constant := 6.28318_53071_79586_47692_52867_66559_00576_8394; begin -- Argument reduction by "rem" Y := Common_Float( X ); if (Y > 0.0) then Sign_Y := 1.0; else Sign_Y := -1.0; Y := abs(Y); end if; User_Period := Common_Float( Cycle ); if User_Period <= 0.0 then raise Argument_Error; end if; R := Y rem User_Period; K := Round( 4.0*R / User_Period ); I_Flag := Quadrant_Flag( Integer(K) mod 4 ); SC_Flag := I_Flag mod 2; P_Lead := Leading_Part( User_Period, 4 ); P_Trail := User_Period - P_Lead; K := K * 0.25; R := (R - K*P_Lead) - K*P_Trail; R := (R/User_Period) * Two_Pi; U := KF_Sin(R, Zero); V := KF_Cos(R, Zero); if (SC_Flag = 0) then if (V = 0.0) then raise Constraint_Error; end if; Z := U / V; else if (U = 0.0) then raise Constraint_Error; end if; Z := -V / U; end if; return( Float_Type( Sign_Y * Z ) ); end KF_TanCy;