Back to Aurora Vision Library Lite website

You are here: Start » Basic » String » FormatIntegerToString

FormatIntegerToString


Header: STD.h
Namespace: avl

Creates a string from an integer number using a proper format.

Applications: Useful for preparing a number for display or communication with specific number of digits, sign etc.

Syntax

void avl::FormatIntegerToString
(
	const int inInteger,
	const int inDigitCount,
	const atl::String& inTrailingCharacter,
	const bool inForceSignPrinting,
	const atl::String& inSuffix,
	const int inSystemBase,
	atl::String& outString
)

Parameters

Name Type Range Default Description
Input value inInteger const int Input integer
Input value inDigitCount const int 0 - 100 How many characters the output string should have at least
Input value inTrailingCharacter const String& \"0\" Defines the trailing character
Input value inForceSignPrinting const bool False Forces printing the sign of the number even if the number is positive
Input value inSuffix const String& \"\" Defines a suffix. Generally it is an unit of value (e.g. mm)
Input value inSystemBase const int 2 - 16 10 The base of the numeral system
Output value outString String& Output string

Examples

inInteger = 200
inDigitCount = 4
inTrailingCharacter = "0"
inForceSignPrinting = False
inSuffix = ""
inSystemBase = 16
outString = "00C8"

In the above example the input value is 200. Formatting is configured for displaying 4-digit hexadecimal number by setting the inDigitCount input. The value of 200 expressed in hexadecimal numeral system is represented as 0xC8. The final result is filled in with zeros.

inInteger = 25
inDigitCount = 4
inTrailingCharacter = "-"
inForceSignPrinting = False
inSuffix = ""
inSystemBase = 10
outString = "--25"

The next example shows you how final representation of a number can be filled with arbitrary chosen sign. First two characters are dashes as defined in inTrailingCharacter.

Errors

List of possible exceptions:

Error type Description
DomainError inTrailingCharacter has to be a single character in FormatIntegerToString.

See Also

  • FormatString – Creates a string according to the given format and data.