blob: 216f147884ea724350e2064aeffe8097c0cd580e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
/**
** @file cvtdec.c
**
** @author Numerous CSCI-452 classes
**
** @brief C implementations of common library functions
*/
#ifndef CVTDEC_SRC_INC
#define CVTDEC_SRC_INC
#include <common.h>
#include <lib.h>
/**
** cvtdec(buf,value)
**
** convert a 32-bit signed value into a NUL-terminated character string
**
** @param buf Destination buffer
** @param value Value to convert
**
** @return The number of characters placed into the buffer
** (not including the NUL)
**
** NOTE: assumes buf is large enough to hold the resulting string
*/
int cvtdec( char *buf, int32_t value ) {
char *bp = buf;
if( value < 0 ) {
*bp++ = '-';
value = -value;
}
bp = cvtdec0( bp, value );
*bp = '\0';
return( bp - buf );
}
#endif
|