MoSync 3.3
mastdlib.h File Reference

String conversion and pseudo-random number generation. More...

#include "ma.h"
#include "maxtoa.h"

Classes

struct  div_t
 Type that contains the quotient and reminder of a divison. More...

Defines

#define RAND_MAX   0x7fffffff

Typedefs

typedef struct div_t div_t
 Type that contains the quotient and reminder of a divison.

Functions

int atoi (const char *string)
 Converts ASCII number to integer.
long atol (const char *string)
div_t div (int numer, int denom)
int axtoi (const char *hexStg)
 Hexadecimal ASCII number to integer.
long strtol (const char *nptr, char **endptr, int base)
unsigned long strtoul (const char *nptr, char **endptr, int base)
unsigned long long strtoull (const char *nptr, char **endptr, int base)
char ConvertUtf8ToLatin1 (const char *utf8, int *pnBytes) __attribute__((deprecated))
int StringEqual_utf8_latin1 (const char *utf8, const char *latin1) __attribute__((deprecated))
int find (const char *a, char b)
int rand (void)
 Generate and return 31-bit random value.
int urand (void)
 Generate and return 32-bit random value.
void srand (unsigned int seed)
 Initialize random number generator.
int abs (int x)
void bzero (void *s, size_t n)

Detailed Description

String conversion and pseudo-random number generation.


Define Documentation

#define RAND_MAX   0x7fffffff

Typedef Documentation

typedef struct div_t div_t

Type that contains the quotient and reminder of a divison.


Function Documentation

int atoi ( const char *  string)

Converts ASCII number to integer.

Parameters:
stringA string containing a number.
Returns:
An integer
long atol ( const char *  string)
See also:
atoi
div_t div ( int  numer,
int  denom 
)
int axtoi ( const char *  hexStg)

Hexadecimal ASCII number to integer.

Parameters:
hexStgA string containing a hexadecimal number.
long strtol ( const char *  nptr,
char **  endptr,
int  base 
)
unsigned long strtoul ( const char *  nptr,
char **  endptr,
int  base 
)
unsigned long long strtoull ( const char *  nptr,
char **  endptr,
int  base 
)
char ConvertUtf8ToLatin1 ( const char *  utf8,
int *  pnBytes 
)

Converts one UTF8 character to Latin-1.

Parameters:
utf8A pointer to a UTF8 character.
pnBytesA pointer to an integer that gets the length in bytes of the UTF8 character.
Returns:
The converted character.
int StringEqual_utf8_latin1 ( const char *  utf8,
const char *  latin1 
)

Compares a UTF8 string with a Latin-1 string.

Parameters:
utf8A pointer to a UTF8 string.
latin1A pointer to a latin1 string.
Returns:
TRUE if the strings matched, FALSE otherwise
int find ( const char *  a,
char  b 
)

Finds the first occurance of a character in a string

Parameters:
aThe character to find.
bThe string in which to search.
Returns:
Returns an integer index to the first occurance of the character, or NULL if the character was not found.
int rand ( void  )

Generate and return 31-bit random value.

Returns a pseudo-random integral number in the range 0 to RAND_MAX.

int urand ( void  )

Generate and return 32-bit random value.

Returns a pseudo-random number in the range 0 to 0xFFFF FFFF.

void srand ( unsigned int  seed)

Initialize random number generator.

The pseudo-random number generator is initialized using the argument passed as seed. For every different seed value used in a call to srand, the pseudo-random number generator can be expected to generate a different succession of results in the subsequent calls to rand. Two different initializations with the same seed, instructs the pseudo-random generator to generate the same succession of results for the subsequent calls to rand in both cases. If seed is set to 1, the generator is reinitialized to its initial value and produces the same values as before any call to rand or srand. In order to generate random-like numbers, srand is usually initialized to some distinctive value, like those related with the execution time.

Parameters:
seedAn integer value to be used as seed by the pseudo-random number generator algorithm.
int abs ( int  x)

Returns the absolute value of x.

void bzero ( void *  s,
size_t  n 
)

Places n zero-valued bytes in the area pointed to by s.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines