Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-nRF5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-nRF5
Commits
941bacc7
Commit
941bacc7
authored
Mar 25, 2016
by
Sandeep Mistry
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Put back ltoa and ultoa functions
parent
b55555cd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
128 deletions
+70
-128
cores/nRF52/itoa.c
cores/nRF52/itoa.c
+70
-124
cores/nRF52/itoa.h
cores/nRF52/itoa.h
+0
-4
No files found.
cores/nRF52/itoa.c
View file @
941bacc7
...
...
@@ -23,147 +23,93 @@
extern
"C"
{
#endif
/* reverse: reverse string s in place */
/*
static void reverse( char s[] )
extern
char
*
ltoa
(
long
value
,
char
*
string
,
int
radix
)
{
int i, j ;
char c ;
char
tmp
[
33
];
char
*
tp
=
tmp
;
long
i
;
unsigned
long
v
;
int
sign
;
char
*
sp
;
if
(
string
==
NULL
)
{
return
0
;
}
if
(
radix
>
36
||
radix
<=
1
)
{
return
0
;
}
sign
=
(
radix
==
10
&&
value
<
0
);
if
(
sign
)
{
v
=
-
value
;
}
else
{
v
=
(
unsigned
long
)
value
;
}
for ( i = 0, j = strlen(s)-1 ; i < j ; i++, j--
)
while
(
v
||
tp
==
tmp
)
{
c = s[i] ;
s[i] = s[j] ;
s[j] = c ;
i
=
v
%
radix
;
v
=
v
/
radix
;
if
(
i
<
10
)
*
tp
++
=
i
+
'0'
;
else
*
tp
++
=
i
+
'a'
-
10
;
}
sp
=
string
;
if
(
sign
)
*
sp
++
=
'-'
;
while
(
tp
>
tmp
)
*
sp
++
=
*--
tp
;
*
sp
=
0
;
return
string
;
}
*/
/* itoa: convert n to characters in s */
/*
extern void itoa( int n, char s[] )
extern
char
*
ultoa
(
unsigned
long
value
,
char
*
string
,
int
radix
)
{
int i, sign ;
char
tmp
[
33
];
char
*
tp
=
tmp
;
long
i
;
unsigned
long
v
=
value
;
char
*
sp
;
if (
(sign = n) < 0 ) // record sign
if
(
string
==
NULL
)
{
n = -n; // make n positive
return
0
;
}
i = 0;
do
{ // generate digits in reverse order
s[i++] = n % 10 + '0'; // get next digit
} while ((n /= 10) > 0) ; // delete it
if
(
radix
>
36
||
radix
<=
1
)
{
return
0
;
}
if (sign < 0
)
while
(
v
||
tp
==
tmp
)
{
s[i++] = '-';
i
=
v
%
radix
;
v
=
v
/
radix
;
if
(
i
<
10
)
*
tp
++
=
i
+
'0'
;
else
*
tp
++
=
i
+
'a'
-
10
;
}
s
[i] = '\0'
;
s
p
=
string
;
reverse( s ) ;
}
*/
// extern char* itoa( int value, char *string, int radix )
// {
// return ltoa( value, string, radix ) ;
// }
// extern char* ltoa( long value, char *string, int radix )
// {
// char tmp[33];
// char *tp = tmp;
// long i;
// unsigned long v;
// int sign;
// char *sp;
// if ( string == NULL )
// {
// return 0 ;
// }
// if (radix > 36 || radix <= 1)
// {
// return 0 ;
// }
// sign = (radix == 10 && value < 0);
// if (sign)
// {
// v = -value;
// }
// else
// {
// v = (unsigned long)value;
// }
// while (v || tp == tmp)
// {
// i = v % radix;
// v = v / radix;
// if (i < 10)
// *tp++ = i+'0';
// else
// *tp++ = i + 'a' - 10;
// }
// sp = string;
// if (sign)
// *sp++ = '-';
// while (tp > tmp)
// *sp++ = *--tp;
// *sp = 0;
// return string;
// }
// // extern char* utoa( unsigned long value, char *string, int radix )
// // {
// // return ultoa( value, string, radix ) ;
// // }
// extern char* ultoa( unsigned long value, char *string, int radix )
// {
// char tmp[33];
// char *tp = tmp;
// long i;
// unsigned long v = value;
// char *sp;
// if ( string == NULL )
// {
// return 0;
// }
// if (radix > 36 || radix <= 1)
// {
// return 0;
// }
// while (v || tp == tmp)
// {
// i = v % radix;
// v = v / radix;
// if (i < 10)
// *tp++ = i+'0';
// else
// *tp++ = i + 'a' - 10;
// }
// sp = string;
// while (tp > tmp)
// *sp++ = *--tp;
// *sp = 0;
// return string;
// }
while
(
tp
>
tmp
)
*
sp
++
=
*--
tp
;
*
sp
=
0
;
return
string
;
}
#ifdef __cplusplus
}
// extern "C"
...
...
cores/nRF52/itoa.h
View file @
941bacc7
...
...
@@ -22,11 +22,7 @@
extern
"C"
{
#endif
//extern void itoa( int n, char s[] ) ;
// extern char* itoa( int value, char *string, int radix ) ;
extern
char
*
ltoa
(
long
value
,
char
*
string
,
int
radix
)
;
// extern char* utoa( unsigned long value, char *string, int radix ) ;
extern
char
*
ultoa
(
unsigned
long
value
,
char
*
string
,
int
radix
)
;
#ifdef __cplusplus
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment