.TH "avr_stdlib" 3avr "Fri Jan 1 2021" "Version 2.0.0" "avr-libc" \" -*- nroff -*- .ad l .nh .SH NAME avr_stdlib \- : General utilities .SH SYNOPSIS .br .PP .SS "Functions" .in +1c .ti -1c .RI "double \fBatof\fP (const char *__nptr)" .br .in -1c .SS "Non-standard (i\&.e\&. non-ISO C) functions\&." .in +1c .ti -1c .RI "char * \fBltoa\fP (long val, char *s, int radix)" .br .ti -1c .RI "char * \fButoa\fP (unsigned int val, char *s, int radix)" .br .ti -1c .RI "char * \fBultoa\fP (unsigned long val, char *s, int radix)" .br .ti -1c .RI "long \fBrandom\fP (void)" .br .ti -1c .RI "void \fBsrandom\fP (unsigned long __seed)" .br .ti -1c .RI "long \fBrandom_r\fP (unsigned long *__ctx)" .br .ti -1c .RI "char * \fBitoa\fP (int val, char *s, int radix)" .br .ti -1c .RI "#define \fBRANDOM_MAX\fP 0x7FFFFFFF" .br .in -1c .SS "Conversion functions for double arguments\&." Note that these functions are not located in the default library, \fClibc\&.a\fP, but in the mathematical library, \fClibm\&.a\fP\&. So when linking the application, the \fC-lm\fP option needs to be specified\&. .in +1c .ti -1c .RI "char * \fBdtostre\fP (double __val, char *__s, unsigned char __prec, unsigned char __flags)" .br .ti -1c .RI "char * \fBdtostrf\fP (double __val, signed char __width, unsigned char __prec, char *__s)" .br .ti -1c .RI "#define \fBDTOSTR_ALWAYS_SIGN\fP 0x01 /* put '+' or ' ' for positives */" .br .ti -1c .RI "#define \fBDTOSTR_PLUS_SIGN\fP 0x02 /* put '+' rather than ' ' */" .br .ti -1c .RI "#define \fBDTOSTR_UPPERCASE\fP 0x04 /* put 'E' rather 'e' */" .br .ti -1c .RI "#define \fBEXIT_SUCCESS\fP 0" .br .ti -1c .RI "#define \fBEXIT_FAILURE\fP 1" .br .in -1c .SH "Detailed Description" .PP .PP .nf #include .fi .PP .PP This file declares some basic C macros and functions as defined by the ISO standard, plus some AVR-specific extensions\&. .SH "Macro Definition Documentation" .PP .SS "#define DTOSTR_ALWAYS_SIGN 0x01 /* put '+' or ' ' for positives */" Bit value that can be passed in \fCflags\fP to \fBdtostre()\fP\&. .SS "#define DTOSTR_PLUS_SIGN 0x02 /* put '+' rather than ' ' */" Bit value that can be passed in \fCflags\fP to \fBdtostre()\fP\&. .SS "#define DTOSTR_UPPERCASE 0x04 /* put 'E' rather 'e' */" Bit value that can be passed in \fCflags\fP to \fBdtostre()\fP\&. .SS "#define EXIT_FAILURE 1" Unsuccessful termination for \fBexit()\fP; evaluates to a non-zero value\&. .SS "#define EXIT_SUCCESS 0" Successful termination for \fBexit()\fP; evaluates to 0\&. .SS "#define RANDOM_MAX 0x7FFFFFFF" Highest number that can be generated by \fBrandom()\fP\&. .SH "Function Documentation" .PP .SS "double atof (const char * nptr)" The \fBatof()\fP function converts the initial portion of the string pointed to by \fInptr\fP to double representation\&. .PP It is equivalent to calling .PP .nf strtod(nptr, (char **)0); .fi .PP .SS "char* dtostre (double __val, char * __s, unsigned char __prec, unsigned char __flags)" The \fBdtostre()\fP function converts the double value passed in \fCval\fP into an ASCII representation that will be stored under \fCs\fP\&. The caller is responsible for providing sufficient storage in \fCs\fP\&. .PP Conversion is done in the format \fC'[-]d\&.ddde±dd'\fP where there is one digit before the decimal-point character and the number of digits after it is equal to the precision \fCprec\fP; if the precision is zero, no decimal-point character appears\&. If \fCflags\fP has the DTOSTR_UPPERCASE bit set, the letter \fC'E'\fP (rather than \fC'e'\fP ) will be used to introduce the exponent\&. The exponent always contains two digits; if the value is zero, the exponent is \fC'00'\fP\&. .PP If \fCflags\fP has the DTOSTR_ALWAYS_SIGN bit set, a space character will be placed into the leading position for positive numbers\&. .PP If \fCflags\fP has the DTOSTR_PLUS_SIGN bit set, a plus sign will be used instead of a space character in this case\&. .PP The \fBdtostre()\fP function returns the pointer to the converted string \fCs\fP\&. .SS "char* dtostrf (double __val, signed char __width, unsigned char __prec, char * __s)" The \fBdtostrf()\fP function converts the double value passed in \fCval\fP into an ASCII representationthat will be stored under \fCs\fP\&. The caller is responsible for providing sufficient storage in \fCs\fP\&. .PP Conversion is done in the format \fC'[-]d\&.ddd'\fP\&. The minimum field width of the output string (including the possible \fC'\fP\&.' and the possible sign for negative values) is given in \fCwidth\fP, and \fCprec\fP determines the number of digits after the decimal sign\&. \fCwidth\fP is signed value, negative for left adjustment\&. .PP The \fBdtostrf()\fP function returns the pointer to the converted string \fCs\fP\&. .SS "char* itoa (int val, char * s, int radix)" .PP Convert an integer to a string\&. The function \fBitoa()\fP converts the integer value from \fCval\fP into an ASCII representation that will be stored under \fCs\fP\&. The caller is responsible for providing sufficient storage in \fCs\fP\&. .PP \fBNote\fP .RS 4 The minimal size of the buffer \fCs\fP depends on the choice of radix\&. For example, if the radix is 2 (binary), you need to supply a buffer with a minimal length of 8 * sizeof (int) + 1 characters, i\&.e\&. one character for each bit plus one for the string terminator\&. Using a larger radix will require a smaller minimal buffer size\&. .RE .PP \fBWarning\fP .RS 4 If the buffer is too small, you risk a buffer overflow\&. .RE .PP Conversion is done using the \fCradix\fP as base, which may be a number between 2 (binary conversion) and up to 36\&. If \fCradix\fP is greater than 10, the next digit after \fC'9'\fP will be the letter \fC'a'\fP\&. .PP If radix is 10 and val is negative, a minus sign will be prepended\&. .PP The \fBitoa()\fP function returns the pointer passed as \fCs\fP\&. .SS "char* ltoa (long val, char * s, int radix)" .PP Convert a long integer to a string\&. The function \fBltoa()\fP converts the long integer value from \fCval\fP into an ASCII representation that will be stored under \fCs\fP\&. The caller is responsible for providing sufficient storage in \fCs\fP\&. .PP \fBNote\fP .RS 4 The minimal size of the buffer \fCs\fP depends on the choice of radix\&. For example, if the radix is 2 (binary), you need to supply a buffer with a minimal length of 8 * sizeof (long int) + 1 characters, i\&.e\&. one character for each bit plus one for the string terminator\&. Using a larger radix will require a smaller minimal buffer size\&. .RE .PP \fBWarning\fP .RS 4 If the buffer is too small, you risk a buffer overflow\&. .RE .PP Conversion is done using the \fCradix\fP as base, which may be a number between 2 (binary conversion) and up to 36\&. If \fCradix\fP is greater than 10, the next digit after \fC'9'\fP will be the letter \fC'a'\fP\&. .PP If radix is 10 and val is negative, a minus sign will be prepended\&. .PP The \fBltoa()\fP function returns the pointer passed as \fCs\fP\&. .SS "long random (void)" The \fBrandom()\fP function computes a sequence of pseudo-random integers in the range of 0 to \fCRANDOM_MAX\fP (as defined by the header file <\fBstdlib\&.h\fP>)\&. .PP The \fBsrandom()\fP function sets its argument \fCseed\fP as the seed for a new sequence of pseudo-random numbers to be returned by \fBrand()\fP\&. These sequences are repeatable by calling \fBsrandom()\fP with the same seed value\&. .PP If no seed value is provided, the functions are automatically seeded with a value of 1\&. .SS "long random_r (unsigned long * __ctx)" Variant of \fBrandom()\fP that stores the context in the user-supplied variable located at \fCctx\fP instead of a static library variable so the function becomes re-entrant\&. .SS "void srandom (unsigned long __seed)" Pseudo-random number generator seeding; see \fBrandom()\fP\&. .SS "char* ultoa (unsigned long val, char * s, int radix)" .PP Convert an unsigned long integer to a string\&. The function \fBultoa()\fP converts the unsigned long integer value from \fCval\fP into an ASCII representation that will be stored under \fCs\fP\&. The caller is responsible for providing sufficient storage in \fCs\fP\&. .PP \fBNote\fP .RS 4 The minimal size of the buffer \fCs\fP depends on the choice of radix\&. For example, if the radix is 2 (binary), you need to supply a buffer with a minimal length of 8 * sizeof (unsigned long int) + 1 characters, i\&.e\&. one character for each bit plus one for the string terminator\&. Using a larger radix will require a smaller minimal buffer size\&. .RE .PP \fBWarning\fP .RS 4 If the buffer is too small, you risk a buffer overflow\&. .RE .PP Conversion is done using the \fCradix\fP as base, which may be a number between 2 (binary conversion) and up to 36\&. If \fCradix\fP is greater than 10, the next digit after \fC'9'\fP will be the letter \fC'a'\fP\&. .PP The \fBultoa()\fP function returns the pointer passed as \fCs\fP\&. .SS "char* utoa (unsigned int val, char * s, int radix)" .PP Convert an unsigned integer to a string\&. The function \fButoa()\fP converts the unsigned integer value from \fCval\fP into an ASCII representation that will be stored under \fCs\fP\&. The caller is responsible for providing sufficient storage in \fCs\fP\&. .PP \fBNote\fP .RS 4 The minimal size of the buffer \fCs\fP depends on the choice of radix\&. For example, if the radix is 2 (binary), you need to supply a buffer with a minimal length of 8 * sizeof (unsigned int) + 1 characters, i\&.e\&. one character for each bit plus one for the string terminator\&. Using a larger radix will require a smaller minimal buffer size\&. .RE .PP \fBWarning\fP .RS 4 If the buffer is too small, you risk a buffer overflow\&. .RE .PP Conversion is done using the \fCradix\fP as base, which may be a number between 2 (binary conversion) and up to 36\&. If \fCradix\fP is greater than 10, the next digit after \fC'9'\fP will be the letter \fC'a'\fP\&. .PP The \fButoa()\fP function returns the pointer passed as \fCs\fP\&. .SH "Author" .PP Generated automatically by Doxygen for avr-libc from the source code\&.