Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Ada Programming/Attributes/'Copy Sign

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

Attributes 'Copy_Sign __TOC__ function S'Copy_Sign (Value, Sign : T) return T Description S'Copy_Sign(X, Y) is an Ada attribute where S is any floating-point type, and X and Y are any instance of that type. This attribute represents the floating point value with the magnitude of X and the sign of Y. If the resulting value is outside the base range of S, a Constraint_Error exception is raised. Example X : Float := 1.5; Y : Float := -1.0; Z : Float := 1.0; Assert (Float'Copy_Sign ( X, Y) = -1.5); OK Assert (Float'Copy_Sign ( X, Z) = 1.5); OK Assert (Float'Copy_Sign (-X, Z) = 1.5); OK Assert (Float'Copy_Sign ( Y, Z) = -1.0); Wrong See also Wikibook Ada Programming Ada Programming/Attributes Ada Reference Manual A 5 3 Attributes of Floating Point Types K Language-Defined Attributes Copy_Sign