Introduction
Downloads
Documentation
Tutorials
Pixie Lite
Forum

Home

StandardLibrary.cpp File Reference

Go to the source code of this file.


Functions

int Round (float x)
void SRand (unsigned int seed)
unsigned int Rand ()
void Randomize ()
int ToUpper (int c)
int ToLower (int c)
int StringToInt (const char *string)
long StringToLong (const char *string)
double StringToDouble (const char *string)
char * StrDup (const char *string)
char * IntToString (int value, char *string, int maxLength)
int SNPrintF (char *buffer, int maxLength, const char *string,...)
int StrNICmp (const char *string1, const char *string2, int count)
int StrNCmp (const char *string1, const char *string2, int count)
int StrICmp (const char *string1, const char *string2)
int StrCmp (const char *string1, const char *string2)
unsigned int StrLen (const char *string)
char * StrCpy (char *strDestination, const char *strSource)
char * StrNCpy (char *strDestination, const char *strSource, int count)
char * StrCat (char *strDestination, const char *strSource)
char * StrNCat (char *strDestination, const char *strSource, int count)
char * StrUpr (char *string)
char * StrLwr (char *string)
const char * StrChr (const char *string, int c)
const char * StrRChr (const char *string, int c)
char * StrTok (char *strToken, const char *strDelimit)
const char * StrStr (const char *str1, const char *str2)
void * Malloc (unsigned int size)
void Free (void *memblock)
void * Realloc (void *memblock, unsigned int size)
void * MemCpy (void *dest, const void *src, unsigned int count)
void * MemSet (void *dest, int c, unsigned int count)
unsigned int MemCmp (const void *a, const void *b, unsigned int count)
void QSort (void *base, size_t num, size_t width, int(__cdecl *compare)(const void *, const void *))
float ToRadians (float degrees)
float ToDegrees (float radians)
float AngleDiff (float angleA, float angleB)
float Abs (float x)
int Abs (int x)
float Sqrt (float x)
float Mod (float x, float y)
float Sin (float x)
float ASin (float x)
float Cos (float x)
float ACos (float x)
float Tan (float x)
float ATan (float x)
float Atan2 (float x, float y)
float Log10 (float x)
int Pow (int x, int y)
float Pow (float x, float y)
float Exp (float x)
float Log (float x)
float Max (float a, float b)
float Min (float a, float b)
int Max (int a, int b)
int Min (int a, int b)
int Clamp (int value, int min, int max)
float Clamp (float value, float min, float max)
void Swap (int &x, int &y)
void Swap (unsigned int &x, unsigned int &y)
void Swap (float &x, float &y)

Variables

Random standardLibrary_random

Function Documentation

int Round ( float  x  ) 

Rounds the specified float value to the nearest integer value. On some CPU's (such as x86), this is much faster than truncating the value by casting to int.

Returns:
the nearest integer value

Definition at line 17 of file StandardLibrary.cpp.

void SRand ( unsigned int  seed  ) 

The SRand function sets the starting point for generating a series of pseudorandom integers. To reinitialize the generator, use 1 as the seed argument. Rand retrieves the pseudorandom numbers that are generated. Calling Rand before any call to SRand generates the same sequence as calling SRand with seed passed as 1.

Parameters:
seed Seed for random-number generation

Definition at line 39 of file StandardLibrary.cpp.

unsigned int Rand (  ) 

The Rand function returns a pseudorandom integer in the range 0 to RANDOM_MAX. Use the SRand function to seed the pseudorandom-number generator before calling Rand.

Returns:
a pseudorandom number, as described above. There is no error return.

Definition at line 53 of file StandardLibrary.cpp.

void Randomize (  ) 

The Randomize function sets the starting point for generating a series of pseudorandom integers to a random starting point. It is the equivalent of calling SRand passing it the current time as a seed value.

Definition at line 63 of file StandardLibrary.cpp.

int ToUpper ( int  c  ) 

Convert character to uppercase

Parameters:
c Character to convert.

Definition at line 74 of file StandardLibrary.cpp.

int ToLower ( int  c  ) 

Convert character to lowercase

Parameters:
c Character to convert.

Definition at line 82 of file StandardLibrary.cpp.

int StringToInt ( const char *  string  ) 

This function convert a character string to an integer value The input string is a sequence of characters that can be interpreted as a numerical value of the specified type. The function stops reading the input string at the first character that it cannot recognize as part of a number. This character may be the null character ('') terminating the string.

Returns:
the int value produced by interpreting the input characters as a number. The return value is 0 if the input cannot be converted to a value of that type. The return value is undefined in case of overflow.
Parameters:
string String to be converted.

Definition at line 90 of file StandardLibrary.cpp.

long StringToLong ( const char *  string  ) 

This function convert a character string to a long integer value The input string is a sequence of characters that can be interpreted as a numerical value of the specified type. The function stops reading the input string at the first character that it cannot recognize as part of a number. This character may be the null character ('') terminating the string.

The string argument has the form:

[whitespace] [sign]digits

A whitespace consists of space or tab characters, which are ignored; sign is either plus (+) or minus ( - ); and digits are one or more decimal digits.

Returns:
the long value produced by interpreting the input characters as a number. The return value is 0L if the input cannot be converted to a value of that type. The return value is undefined in case of overflow.
Parameters:
string String to be converted.

Definition at line 98 of file StandardLibrary.cpp.

double StringToDouble ( const char *  string  ) 

This function convert a character string to a double precision floating point value The input string is a sequence of characters that can be interpreted as a numerical value of the specified type. The function stops reading the input string at the first character that it cannot recognize as part of a number. This character may be the null character ('') terminating the string.

The string argument has the following form:

[whitespace] [sign] [digits] [.digits] [ {d | D | e | E }[sign]digits]

A whitespace consists of space or tab characters, which are ignored; sign is either plus (+) or minus ( - ); and digits are one or more decimal digits. If no digits appear before the decimal point, at least one must appear after the decimal point. The decimal digits may be followed by an exponent, which consists of an introductory letter (d, D, e, or E) and an optionally signed decimal integer.

Returns:
the double value produced by interpreting the input characters as a number. The return value is 0.0 if the input cannot be converted to a value of that type. The return value is undefined in case of overflow.
Parameters:
string String to be converted.

Definition at line 106 of file StandardLibrary.cpp.

char* StrDup ( const char *  string  ) 

The StrDup function calls Malloc to allocate storage space for a copy of strSource and then copies strSource to the allocated space. Because StrDup calls Malloc to allocate storage space for the copy of strSource, it is good practice always to release this memory by calling the Free routine on the pointer returned by the call to StrDup.

Returns:
a pointer to the storage location for the copied string or NULL if storage cannot be allocated.
Parameters:
string Null-terminated source string.

Definition at line 114 of file StandardLibrary.cpp.

char* IntToString ( int  value,
char *  string,
int  maxLength 
)

Definition at line 122 of file StandardLibrary.cpp.

int SNPrintF ( char *  buffer,
int  maxLength,
const char *  string,
  ... 
)

The SNPrintF function formats and stores count or fewer characters and values (including a terminating null character that is always appended unless count is zero or the formatted string length is greater than or equal to count characters) in buffer. Each argument (if any) is converted and output according to the corresponding format specification in format. If copying occurs between strings that overlap, the behavior is undefined.

Security Note Ensure that format is not a user-defined string. This function does not guarantee NULL termination, so ensure it is followed by sz[ ARRAYSIZE(sz) - 1] = 0.

Returns:
the number of bytes stored in buffer, not counting the terminating null character. If the number of bytes required to store the data exceeds count, then count bytes of data are stored in buffer and a negative value is returned.
Parameters:
buffer Storage location for output.
maxLength Maximum number of characters to store.
string Format-control string.

Definition at line 148 of file StandardLibrary.cpp.

int StrNICmp ( const char *  string1,
const char *  string2,
int  count 
)

The StrNICmp function lexicographically compares, at most, the first count characters of string1 and string2. The comparison is performed without regard to case; StrNICmp is a case-insensitive version of StrNCmp. The comparison ends if a terminating null character is reached in either string before count characters are compared. If the strings are equal when a terminating null character is reached in either string before count characters are compared, the shorter string is lesser.

Two strings containing characters located between 'Z' and 'a' in the ASCII table ('[', '\', ']', '^', '_', and '`') compare differently, depending on their case. For example, the two strings "ABCDE" and "ABCD^" compare one way if the comparison is lowercase ("abcde" > "abcd^") and the other way ("ABCDE" < "ABCD^") if it is uppercase.

Returns:
< 0 if string1 substring less than string2 substring, 0 if string1 substring identical to string2 substring, and > 0 if string1 substring greater than string2 substring
Parameters:
string1 Null-terminated strings to compare
string2 Null-terminated strings to compare
count Number of characters to compare

Definition at line 160 of file StandardLibrary.cpp.

int StrNCmp ( const char *  string1,
const char *  string2,
int  count 
)

The StrNCmp function lexicographically compares, at most, the first count characters in string1 and string2 and returns a value indicating the relationship between the substrings. StrNCmp is a case-sensitive version of StrNICmp.

Returns:
< 0 if string1 substring less than string2 substring, 0 if string1 substring identical to string2 substring, and > 0 if string1 substring greater than string2 substring
Parameters:
string1 Null-terminated strings to compare
string2 Null-terminated strings to compare
count Number of characters to compare.

Definition at line 168 of file StandardLibrary.cpp.

int StrICmp ( const char *  string1,
const char *  string2 
)

The StrICmp function lexicographically compares lowercase versions of string1 and string2 and returns a value indicating their relationship. Because StrICmp does lowercase comparisons, it may result in unexpected behavior. To illustrate when case conversion by StrICmp affects the outcome of a comparison, assume that you have the two strings JOHNSTON and JOHN_HENRY. The string JOHN_HENRY will be considered less than JOHNSTON because the "_" has a lower ASCII value than a lowercase S. In fact, any character that has an ASCII value between 91 and 96 will be considered less than any letter. If the StrCmp function is used instead of stricmp, JOHN_HENRY will be greater than JOHNSTON.

Returns:
< 0 if string1 less than string2, 0 if string1 identical to string2 and > 0 if string1 greater than string2
Parameters:
string1 Null-terminated strings to compare
string2 Null-terminated strings to compare

Definition at line 176 of file StandardLibrary.cpp.

int StrCmp ( const char *  string1,
const char *  string2 
)

The StrCmp function compares string1 and string2 lexicographically and returns a value indicating their relationship.

Returns:
< 0 if string1 less than string2, 0 if string1 identical to string2 and > 0 if string1 greater than string2
Parameters:
string1 Null-terminated strings to compare
string2 Null-terminated strings to compare

Definition at line 184 of file StandardLibrary.cpp.

unsigned int StrLen ( const char *  string  ) 

Returns the number of characters in string, not including the terminating null character.

Security Note This function incur a potential threat brought about by a buffer overrun problem. Buffer overrun problems are a frequent method of system attack, resulting in an unwarranted elevation of privilege.

Returns:
the number of characters in string, excluding the terminal NULL. No return value is reserved to indicate an error.
Parameters:
string Null-terminated string.

Definition at line 192 of file StandardLibrary.cpp.

char* StrCpy ( char *  strDestination,
const char *  strSource 
)

The StrCpy function copies strSource, including the terminating null character, to the location specified by strDestination. The behavior of StrCpy is undefined if the source and destination strings overlap.

Security Note Because StrCpy does not check for sufficient space in strDestination before copying strSource, it is a potential cause of buffer overruns. Consider using StrNCpy instead.

Returns:
the destination string. No return value is reserved to indicate an error.
Parameters:
strDestination Destination string.
strSource Null-terminated source string.

Definition at line 200 of file StandardLibrary.cpp.

char* StrNCpy ( char *  strDestination,
const char *  strSource,
int  count 
)

The StrNCpy function copies the initial count characters of strSource to strDestination and returns strDestination. If count is less than or equal to the length of strSource, a null character is not appended automatically to the copied string. If count is greater than the length of strSource, the destination string is padded with null characters up to length count. The behavior of StrNCpy is undefined if the source and destination strings overlap.

Security Note StrNCpy does not check for sufficient space in strDestination; it is therefore a potential cause of buffer overruns. Keep in mind that count limits the number of characters copied; it is not a limit on the size of strDestination.

Returns:
the destination string. No return value is reserved to indicate an error.
Parameters:
strDestination Destination string.
strSource Null-terminated source string.
count Number of characters to be copied.

Definition at line 208 of file StandardLibrary.cpp.

char* StrCat ( char *  strDestination,
const char *  strSource 
)

The strcat function appends strSource to strDestination and terminates the resulting string with a null character. The initial character of strSource overwrites the terminating null character of strDestination. The behavior of strcat is undefined if the source and destination strings overlap.

Security Note Because StrCat does not check for sufficient space in strDestination before appending strSource, it is a potential cause of buffer overruns. Consider using StrNCat instead.

Returns:
the destination string (strDestination). No return value is reserved to indicate an error.
Parameters:
strDestination Null-terminated destination string.
strSource Null-terminated source string.

Definition at line 216 of file StandardLibrary.cpp.

char* StrNCat ( char *  strDestination,
const char *  strSource,
int  count 
)

The StrNCat function appends, at most, the first count characters of strSource to strDestination. The initial character of strSource overwrites the terminating null character of strDestination. If a null character appears in strSource before count characters are appended, StrNCat appends all characters from strSource, up to the null character. If count is greater than the length of strSource, the length of strSource is used in place of count. The resulting string is terminated with a null character. If copying takes place between strings that overlap, the behavior is undefined.

Security Note StrNCat does not check for sufficient space in strDestination; it is therefore a potential cause of buffer overruns. Keep in mind that count limits the number of characters appended; it is not a limit on the size of strDestination.

Returns:
the destination string (strDestination). No return value is reserved to indicate an error.
Parameters:
strDestination Null-terminated destination string.
strSource Null-terminated source string.
count Number of characters to append.

Definition at line 224 of file StandardLibrary.cpp.

char* StrUpr ( char *  string  ) 

The StrUpr function converts, in place, each lowercase letter in string to uppercase

Returns:
a pointer to the altered string. Because the modification is done in place, the pointer returned is the same as the pointer passed as the input argument. No return value is reserved to indicate an error.
Parameters:
string Null-terminated string to capitalize.

Definition at line 232 of file StandardLibrary.cpp.

char* StrLwr ( char *  string  ) 

The StrLwr function converts, in place, each uppercase letter in string to lowercase

Returns:
a pointer to the altered string. Because the modification is done in place, the pointer returned is the same as the pointer passed as the input argument. No return value is reserved to indicate an error
Parameters:
string Null-terminated string to convert to lowercase.

Definition at line 240 of file StandardLibrary.cpp.

const char* StrChr ( const char *  string,
int  c 
)

The StrChr function finds the first occurrence of c in string, or it returns NULL if c is not found. The null- terminating character is included in the search.

Returns:
A pointer to the first occurrence of c in string, or NULL if c is not found.
Parameters:
string Null-terminated string to search.
c Character to be located.

Definition at line 248 of file StandardLibrary.cpp.

const char* StrRChr ( const char *  string,
int  c 
)

The StrRChr function finds the last occurrence of c (converted to char) in string. The search includes the terminating null character.

Returns:
a pointer to the last occurrence of c in string, or NULL if c is not found.
Parameters:
string Null-terminated string to search.
c Character to be located.

Definition at line 256 of file StandardLibrary.cpp.

char* StrTok ( char *  strToken,
const char *  strDelimit 
)

The StrTok function finds the next token in strToken. The set of characters in strDelimit specifies possible delimiters of the token to be found in strToken on the current call.

On the first call to StrTok, the function skips leading delimiters and returns a pointer to the first token in strToken, terminating the token with a null character. More tokens can be broken out of the remainder of strToken by a series of calls to StrTok. Each call to StrTok modifies strToken by inserting a null character after the token returned by that call. To read the next token from strToken, call strtok with a NULL value for the strToken argument. The NULL strToken argument causes StrTok to search for the next token in the modified strToken. The strDelimit argument can take any value from one call to the next so that the set of delimiters may vary.

Note This function uses a static variable for parsing the string into tokens. If multiple or simultaneous calls are made to StrTok, a high potential for data corruption and inaccurate results exists. Therefore, do not attempt to call StrTok simultaneously for different strings and be aware of calling this function from within a loop where another routine may be called that uses the same function. However, calling this function simultaneously from multiple threads does not have undesirable effects.

Returns:
a pointer to the next token found in strToken. Returns NULL when no more tokens are found. Each call modifies strToken by substituting a NULL character for each delimiter that is encountered.
Parameters:
strToken String containing token or tokens.
strDelimit Set of delimiter characters.

Definition at line 264 of file StandardLibrary.cpp.

const char* StrStr ( const char *  str1,
const char *  str2 
)

The strstr function returns a pointer to the first occurrence of strSearch in string. The search does not include terminating null characters.

Returns:
a pointer to the first occurrence of strSearch in string, or NULL if strSearch does not appear in string. If strSearch points to a string of zero length, the function returns string.
Parameters:
str1 Null-terminated string to search.
str2 Null-terminated string to search for.

Definition at line 272 of file StandardLibrary.cpp.

void* Malloc ( unsigned int  size  ) 

The Malloc function allocates a memory block of at least size bytes. The block may be larger than size bytes because of space required for alignment and maintenance information.

Returns:
A void pointer to the allocated space, or NULL if there is insufficient memory available. To return a pointer to a type other than void, use a type cast on the return value. The storage space pointed to by the return value is guaranteed to be suitably aligned for storage of any type of object. If size is 0, Malloc allocates a zero-length item in the heap and returns a valid pointer to that item. Always check the return from Malloc, even if the amount of memory requested is small.
Parameters:
size Bytes to allocate.

Definition at line 280 of file StandardLibrary.cpp.

void Free ( void *  memblock  ) 

`The free function deallocates a memory block (memblock) that was previously allocated by a call to Malloc or Realloc. The number of freed bytes is equivalent to the number of bytes requested when the block was allocated (or reallocated, in the case of realloc). If memblock is NULL, the pointer is ignored and free immediately returns. Attempting to free an invalid pointer (a pointer to a memory block that was not allocated by Malloc or Realloc) may affect subsequent allocation requests and cause errors.

Parameters:
memblock Previously allocated memory block to be freed.

Definition at line 290 of file StandardLibrary.cpp.

void* Realloc ( void *  memblock,
unsigned int  size 
)

The Realloc function changes the size of an allocated memory block. The memblock argument points to the beginning of the memory block. If memblock is NULL, Realloc behaves the same way as Malloc and allocates a new block of size bytes. If memblock is not NULL, it should be a pointer returned by a previous call to malloc or realloc.

The size argument gives the new size of the block, in bytes. The contents of the block are unchanged up to the shorter of the new and old sizes, although the new block can be in a different location. Because the new block can be in a new memory location, the pointer returned by Realloc is not guaranteed to be the pointer passed through the memblock argument.

Returns:
A void pointer to the reallocated (and possibly moved) memory block. The return value is NULL if the size is zero and the buffer argument is not NULL, or if there is not enough available memory to expand the block to the given size. In the first case, the original block is freed. In the second, the original block is unchanged. The return value points to a storage space that is guaranteed to be suitably aligned for storage of any type of object. To get a pointer to a type other than void, use a type cast on the return value.
Parameters:
memblock Pointer to previously allocated memory block.
size New size in bytes.

Definition at line 298 of file StandardLibrary.cpp.

void* MemCpy ( void *  dest,
const void *  src,
unsigned int  count 
)

Copies count bytes of src to dest. If the source and destination overlap, the behavior of memcpy is undefined.

Security Note Make sure that the destination buffer is the same size or larger than the source buffer.

Returns:
The value of dest.
Parameters:
dest New buffer.
src Buffer to copy from.
count Number of bytes to copy.

Definition at line 308 of file StandardLibrary.cpp.

void* MemSet ( void *  dest,
int  c,
unsigned int  count 
)

Sets the first count chars of dest to the character c.

Security Note Make sure that the destination buffer is the same size or larger than the source buffer.

Returns:
The value of dest.
Parameters:
dest Pointer to destination.
c Character to set.
count Number of characters.

Definition at line 316 of file StandardLibrary.cpp.

unsigned int MemCmp ( const void *  buf1,
const void *  buf2,
unsigned int  count 
)

Compares the first count bytes of buf1 and buf2 and returns a value indicating their relationship.

Returns:
< 0 if buf1 less than buf2, 0 if buf1 identical to buf2 and > 0 if buf1 greater than buf2
Parameters:
a First buffer.
b Second buffer.
count Number of bytes.

Definition at line 324 of file StandardLibrary.cpp.

void QSort ( void *  base,
size_t  num,
size_t  width,
int(__cdecl *compare)(const void *, const void *)   
)

The QSort function implements a quick-sort algorithm to sort an array of num elements, each of width bytes. The argument base is a pointer to the base of the array to be sorted. QSort overwrites this array with the sorted elements. The argument compare is a pointer to a user-supplied routine that compares two array elements and returns a value specifying their relationship. QSort calls the compare routine one or more times during the sort, passing pointers to two array elements on each call:

compare( (void *) elem1, (void *) elem2 );

The routine must compare the elements, then return < 0 if elem1 less than elem2, 0 if elem1 equivalent to elem2, and > 0 if elem1 greater than elem2

The array is sorted in increasing order, as defined by the comparison function. To sort an array in decreasing order, reverse the sense of "greater than" and "less than" in the comparison function.

Parameters:
base Start of target array.
num Array size in elements.
width Element size in bytes.

Definition at line 332 of file StandardLibrary.cpp.

float ToRadians ( float  degrees  ) 

Converts an angle from degrees to radians

Returns:
The angle in radians

Definition at line 340 of file StandardLibrary.cpp.

float ToDegrees ( float  radians  ) 

Converts an angle from radians to degrees

Returns:
The angle in degrees

Definition at line 348 of file StandardLibrary.cpp.

float AngleDiff ( float  angleA,
float  angleB 
)

Calculates the difference between two angles. The result is quaranteed to be between -PI and PI, regardless of what angleA and angleB might be

Returns:
The difference between the two angles

Definition at line 356 of file StandardLibrary.cpp.

float Abs ( float  x  ) 

Calculates the absolute value of the floating-point argument.

Returns:
The absolute value of its argument. There is no error return.
Parameters:
x Floating-point value.

Definition at line 383 of file StandardLibrary.cpp.

int Abs ( int  x  ) 

Calculates the absolute value.

Returns:
The absolute value of its parameter. There is no error return.
Parameters:
x Integer value.

Definition at line 391 of file StandardLibrary.cpp.

float Sqrt ( float  x  ) 

Calculates the square root of x. If x is negative, it returns an indefinite.

Returns:
The square-root of x.
Parameters:
x Nonnegative floating-point value

Definition at line 399 of file StandardLibrary.cpp.

float Mod ( float  x,
float  y 
)

Calculates the floating-point remainder of x / y. If the value of y is 0.0, it returns a quiet NaN.

Returns:
The floating-point remainder.
Parameters:
x Floating-point value.
y Floating-point value.

Definition at line 407 of file StandardLibrary.cpp.

float Sin ( float  x  ) 

Calculate sine of x. If x is greater than or equal to 263, or less than or equal to -263, a loss of significance in the result occurs.

Returns:
The sine of x.
Parameters:
x Value whose sine is to be calculated

Definition at line 415 of file StandardLibrary.cpp.

float ASin ( float  x  ) 

The ASin function returns the arcsine of x in the range -PI/2 to PI/2 radians. If x is less than -1 or greater than 1, ASin returns an indefinite by default.

Returns:
The arcsine of x
Parameters:
x Value between -1 and 1 whose arcsine is to be calculated.

Definition at line 423 of file StandardLibrary.cpp.

float Cos ( float  x  ) 

Calculate cosine of x. If x is greater than or equal to 263, or less than or equal to -263, a loss of significance in the result occurs.

Returns:
The cosine of x.
Parameters:
x Value whose cosine is to be calculated

Definition at line 431 of file StandardLibrary.cpp.

float ACos ( float  x  ) 

The ACos function returns the arccosine of x in the range 0 to PI radians. If x is less than -1 or greater than 1, ACos returns an indefinite by default.

Returns:
The arccosine of x
Parameters:
x Value between -1 and 1 whose arccosine is to be calculated.

Definition at line 439 of file StandardLibrary.cpp.

float Tan ( float  x  ) 

Tan returns the tangent of x. If x is greater than or equal to 263, or less than or equal to -263, a loss of significance in the result occurs.

Returns:
The tangent of x
Parameters:
x Angle in radians.

Definition at line 447 of file StandardLibrary.cpp.

float ATan ( float  x  ) 

ATan returns the arctangent of x in the range of -PI/2 to PI/2 radians. If x is 0, ATan returns 0.

Returns:
The arctangent of x
Parameters:
x Value whose arctangent is to be calculated

Definition at line 455 of file StandardLibrary.cpp.

float Atan2 ( float  x,
float  y 
)

Calculates the arctangent of y/x in the range -PI to PI radians. If x is 0, Atan2 returns 0. If both parameters of Atan2 are 0, the function returns 0. Atan2 uses the signs of both parameters to determine the quadrant of the return value. Atan2 is well defined for every point other than the origin, even if x equals 0 and y does not equal 0.

Returns:
the arctangent of y/x
Parameters:
x Any number
y Any number

Definition at line 463 of file StandardLibrary.cpp.

float Log10 ( float  x  ) 

Calculates the base-10 logarithm.

Returns:
The Log10 function return the base-10 logarithm of x if successful. If x is negative, the functions return an indefinite, by default. If x is 0, it return INF (infinite).
Parameters:
x Value whose logarithm is to be found.

Definition at line 471 of file StandardLibrary.cpp.

int Pow ( int  x,
int  y 
)

The Pow function computes x raised to the power of y.

Returns:
The value of x raised to the power of y.
Parameters:
x Base.
y Exponent.

Definition at line 479 of file StandardLibrary.cpp.

float Pow ( float  x,
float  y 
)

The Pow function computes x raised to the power of y.

Returns:
The value of x raised to the power of y.
Parameters:
x Base.
y Exponent.

Definition at line 487 of file StandardLibrary.cpp.

float Exp ( float  x  ) 

The Exp function returns the exponential value of the floating-point parameter, x, if successful. On overflow, the function returns INF (infinite) and on underflow, Exp returns 0.

Returns:
The exponential of x
Parameters:
x Floating-point value.

Definition at line 495 of file StandardLibrary.cpp.

float Log ( float  x  ) 

The Log function return the natural logarithm of x if successful. If x is negative, the function return an indefinite, by default. If x is 0, it return INF (infinite).

Returns:
The natural logarithm of x
Parameters:
x Value whose logarithm is to be found.

Definition at line 503 of file StandardLibrary.cpp.

float Max ( float  a,
float  b 
)

Returns the larger of two values.

Returns:
The larger of its arguments.
Parameters:
a First of the values to be compared
b Second of the values to be compared

Definition at line 511 of file StandardLibrary.cpp.

float Min ( float  a,
float  b 
)

Returns the smaller of two values.

Returns:
The smaller of its arguments.
Parameters:
a First of the values to be compared
b Second of the values to be compared

Definition at line 524 of file StandardLibrary.cpp.

int Max ( int  a,
int  b 
)

Returns the larger of two values.

Returns:
The larger of its arguments.
Parameters:
a First of the values to be compared
b Second of the values to be compared

Definition at line 537 of file StandardLibrary.cpp.

int Min ( int  a,
int  b 
)

Returns the smaller of two values.

Returns:
The smaller of its arguments.
Parameters:
a First of the values to be compared
b Second of the values to be compared

Definition at line 550 of file StandardLibrary.cpp.

int Clamp ( int  value,
int  min,
int  max 
)

Clamps value to the range [min, max].

Returns:
If value is between min and max, it is returned as is. If it is smaller than min, min is returned. If it is larger than max, max is returned.
Parameters:
value Value to clamp
min Min allowed value
max Max allowed value

Definition at line 563 of file StandardLibrary.cpp.

float Clamp ( float  value,
float  min,
float  max 
)

Clamps value to the range [min, max].

Returns:
If value is between min and max, it is returned as is. If it is smaller than min, min is returned. If it is larger than max, max is returned.
Parameters:
value Value to clamp
min Min allowed value
max Max allowed value

Definition at line 579 of file StandardLibrary.cpp.

void Swap ( int &  x,
int &  y 
)

Exchanges the value of variables, assigning the contents of the first variable to the second variable, and the contents of the second to the first.

Parameters:
x First variable
y Second variable

Definition at line 595 of file StandardLibrary.cpp.

void Swap ( unsigned int &  x,
unsigned int &  y 
)

Exchanges the value of variables, assigning the contents of the first variable to the second variable, and the contents of the second to the first.

Parameters:
x First variable
y Second variable

Definition at line 605 of file StandardLibrary.cpp.

void Swap ( float &  x,
float &  y 
)

Exchanges the value of variables, assigning the contents of the first variable to the second variable, and the contents of the second to the first.

Parameters:
x First variable
y Second variable

Definition at line 615 of file StandardLibrary.cpp.


Variable Documentation

Definition at line 35 of file StandardLibrary.cpp.



Pixie University and the Pixie Game Engine is created and managed by Mattias Gustavsson.
Reproduction/republishing of any material on this site without permission is strictly prohibited.