Brief review of programming concepts: functions for numbers and strings
Number functions
Most programming languages support not only the basic arithmetic operations (usually using symbols such as +
, -
, *
, and /
) but also more complex mathematical functions (typically using abbreviated names such as min
for minimum and pow
for power).
When dealing with floating pointA finite representation of a number, which might be an approximation. numbers, it is crucial to know how the functions will behave so that you aren't surprised by what is produced.
String functions
Common built-in string functions include functions that
- determine a character at a particular position
- determine the length of the string
- concatenate two strings (form a new one by gluing the two strings together)
Often, there are also functions that make new strings or transform them in various ways, such as changing lower-case letters to upper-case, and forming substrings.
Typically it is possible compare two strings, where the order of the strings is determined by comparing them in a character-by-character fashion. The order among letters is based on alphabetical order. More generally, any two characters (including digits and punctuation marks) can be compared, using the numerical values assigned to each character by the encoding Unicode.