Sage-ST ä

Convert

Documentation

Global Declarations (Constants, Types, Variables)
BaseStrToNat IntToStr NatToBasePadStr
NatToPercent NatToStr NumberToRoman OVRBaseStrToNat
OVRIntToStr OVRNatToStr OVRStrToInt OVRStrToNat
RomanToNumber StrToInt StrToNat




  Max_Base : constant := 16;

  subtype BaseType is natural range 2 .. Max_Base;




  procedure IntToStr
             (Num   : in     integer;
              Str   :    out string;
              width : in     natural;
              done  :    out boolean);

  --*
  --  IntToStr - Convert Integer to string, can be a fixed size.
  --
  --  This procedure converts an Integer into a string that represents the
  --  number.  There are two modes of using this routine.  If the value of
  --  width is equal to 0 then the value is converted to string in a free
  --  format.  If the value of width is greater than 0 the string is converted
  --  in a fixed format.
  --
  --  Free format - If the value of width is 0 then this format is used.  This
  --  This results in a string that is always left justified and only shows the
  --  sign position if the number is negative.  In this mode the only constraint
  --  to converting is the size of the string that was passed in.
  --
  --  Fixed format - If the value of width is greater than 0 then this format is
  --  used.  In this mode the value is converted to a total length that equals
  --  the size of width.  NOTE - The value of width INCLUDES the sign character
  --  if the number is negative (i.e. the value of -100 requires a width of 4).
  --  If the value is positive it can completely fill the string (i.e. a width
  --  of 4 can handle a positive value up to 9999).
  --
  --  If the string passed is shorter than width or if the converted value will
  --  not fit within the length of the string then SageError #16
  --  (SageErrs.ArrayTooSmall) is generated.
  --
  --  CALLING SEQUENCE -
  --
  --    IntToStr (num, str, width, done)
  --
  --  ENTRY -
  --
  --    num : Integer
  --      The integer to convert.
  --
  --    width : Natural
  --      The string width of the resultant conversion or 0 if left justified.
  --
  --  EXIT -
  --
  --    str : string
  --      The string representing the integer.
  --
  --    done : boolean
  --      Conversion successful (TRUE) or not (FALSE).
  --




  procedure IntToStr
             (Num   : in     ModSys.S_Integer;
              Str   :    out string;
              width : in     natural;
              done  :    out boolean);

  --*
  --  IntToStr - Base IntToStr overloaded for Modsys.S_Integer.
  --




  procedure NatToStr
             (Num   : in     natural;
              Str   :    out string;
              width : in     natural;
              done  :    out boolean);

  --*
  --  NatToStr - Convert Natural to string, can be a fixed size.
  --
  --  This procedure converts a Natural into a string that represents the
  --  number.  There are two modes of using this routine.  If the value of
  --  width is equal to 0 then the value is converted to string in a free
  --  format.  If the value of width is greater than 0 the string is converted
  --  in a fixed format.
  --
  --  Free format - If the value of width is 0 then this format is used.  This
  --  This results in a string that is always left justified.  In this mode the
  --  only constraint to converting is the size of the string that was passed in.
  --
  --  Fixed format - If the value of width is greater than 0 then this format is
  --  used.  In this mode the value is converted to a total length that equals
  --  the size of width (i.e. a width of 4 can handle a value up to 9999).
  --
  --  If the string passed is shorter than width or if the converted value will
  --  not fit within the length of the string then SageError #16
  --  (SageErrs.ArrayTooSmall) is generated.
  --
  --  CALLING SEQUENCE -
  --
  --    NatToStr (num, str, width, done)
  --
  --  ENTRY -
  --
  --    num : Natural
  --      The natural to convert.
  --
  --    width : Natural
  --      The string width of the resultant conversion or 0 if left justified.
  --
  --  EXIT -
  --
  --    str : string
  --      The string representing the natural.
  --
  --    done : boolean
  --      Conversion successful (TRUE) or not (FALSE).
  --




  procedure NatToStr
             (Num   : in     ModSys.S_Natural;
              Str   :    out string;
              width : in     natural;
              done  :    out boolean);

  --*
  --  NatToStr - Base NatToStr overloaded to handle Modsys.S_Natural.
  --
  --  See NatToStr declaration above for details.
  --




  procedure NatToBasePadStr
             (Num   : in     natural;
              Str   :    out string;
              base  : in     BaseType;
              width : in     natural;
              done  :    out boolean);

  --*
  --  NatToBasePadStr - Convert a number into a string in the required base.
  --
  --  This procedure converts a number into a string, representing it within
  --  the requested base.  The resultant string will contain only the digits
  --  (0..9, A..F) available for the specified base with no base indicator.
  --
  --  For example, when a width of 5 is chosen various bases may result in
  --  the following.
  --
  --     base 10     base 2     base 8     base 16
  --     -------     -------    -------    -------
  --     "   29"     "11101"    "   35"    "   1D"
  --
  --  Free format - If the value of width is 0 then this format is used.  This
  --  This results in a string that is always left justified.  In this mode the
  --  only constraint to converting is the size of the string that was passed in.
  --
  --  Fixed format - If the value of width is greater than 0 then this format is
  --  used.  In this mode the value is converted to a total length that equals
  --  the size of width (i.e. a width of 4 can handle a value up to 9999).
  --
  --  If the string passed is shorter than width or if the converted value will
  --  not fit within the length of the string then SageError #16
  --  (SageErrs.ArrayTooSmall) is generated.
  --
  --  CALLING SEQUENCE -
  --
  --    NatToBasePadStr (num, str, base, width, done)
  --
  --  ENTRY -
  --
  --    num : Natural
  --      The natural to convert.
  --
  --    base : BaseType
  --      The base of the number to be represented by the string (2..16).
  --
  --    width : Natural
  --      The string width of the resultant conversion.
  --
  --  EXIT -
  --
  --    str : string
  --      The string representing the long_integer to convert.
  --
  --    done : boolean
  --      Conversion successful (TRUE) or not (FALSE).
  --




  procedure StrToInt
             (Str  : in     string;
              Num  :    out integer;
              done :    out boolean);

  --*
  --  StrToInt - Convert a string into an integer.
  --
  --  This procedure converts a string into an integer value.  Leading
  --  blanks may be present in the string.
  --
  --  CALLING SEQUENCE -
  --
  --    StrToInt (str, num, done)
  --
  --  ENTRY -
  --
  --    str : string
  --      String to convert.
  --
  --  EXIT -
  --
  --    num : Integer
  --      The resultant integer.
  --
  --    done : boolean
  --      The conversion was successful (TRUE) or not (FALSE).
  --




  procedure StrToInt
             (Str  : in     string;
              Num  :    out ModSys.S_Integer;
              done :    out boolean);

  --*
  --  StrToInt - Base StrToInt overloaded to handle Modsys.S_Integer.
  --
  --  See StrToInt declaration above for details.
  --




  procedure StrToNat
             (Str  : in     string;
              Num  :    out natural;
              done :    out boolean);

  --*
  --  StrToNat - Base StrToNat overloaded to handle Natural.
  --
  --  See StrToNat declaration above for details.
  --




  procedure StrToNat
             (Str  : in     string;
              Num  :    out ModSys.S_Natural;
              done :    out boolean);

  --*
  --  StrToNat - Base StrToNat overloaded to handle Modsys.S_Natural.
  --
  --  See StrToNat declaration above for details.
  --




  procedure BaseStrToNat
             (Str  : in     string;
              Num  :    out natural;
              base : in     BaseType;
              done :    out boolean);

  --*
  --  BaseStrToNat - Convert from a Base string to an Integer.
  --
  --  This procedure converts from a number represented in a string
  --  given a specified base to an integer value.
  --
  --  CALLING SEQUENCE -
  --
  --    StrToNat (str, num, base, done)
  --
  --  ENTRY -
  --
  --    str : string
  --      The string containing the number.
  --
  --    base : BaseType
  --      The base of the number as represented in 'str' (2..16).
  --
  --  EXIT -
  --
  --    num : natural
  --      The resultant number from the conversion.
  --
  --    done : boolean
  --      The conversion was successful (TRUE) or not (FALSE).
  --




  procedure BaseStrToNat
             (Str  : in     string;
              Num  :    out ModSys.S_Natural;
              base : in     BaseType;
              done :    out boolean);

  --*
  --  BaseStrToNat - Overload to handle Modsys.S_Natural.
  --




  procedure NumberToRoman
             (Number   : in     ModSys.S_Natural;
              RomanStr :    out string;
              Success  :    out boolean);




  procedure RomanToNumber
             (RomanStr : in     string;
              Number   :    out ModSys.S_Natural;
              Success  :    out boolean);




  procedure NatToPercent
             (NatValue   : in     ModSys.S_Natural;
              TotalValue : in     ModSys.S_Natural;
              NatPercent : in out ModSys.S_Natural;
              StrPercent : in out string);

  --*
  --  NatToPercent - Calculate and return the percent that a number is.
  --




Send mail to   warren.merrill@inl.gov with questions or comments about this web site.
Copyright © 1989-2006 Battelle Energy Alliance