repo.or.cz
/
eigenmath-fx.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Little fix after the last commit (mostly a git fail)
[eigenmath-fx.git]
/
mscan.cpp
blob
2e3e6bc4b8388d605074a22d0e750ddf2f5b7df1
1
// bignum scanner
2
3
#include
"stdafx.h"
4
#include
"defs.h"
5
6
static unsigned int
*
addf
(
unsigned int
*,
int
);
7
static unsigned int
*
mulf
(
unsigned int
*,
int
);
8
9
unsigned int
*
10
mscan
(
char
*
s
)
11
{
12
int
sign
;
13
unsigned int
*
a
, *
b
, *
c
;
14
15
sign
=
1
;
16
17
if
(*
s
==
'-'
) {
18
sign
= -
1
;
19
s
++;
20
}
21
22
a
=
mint
(
0
);
23
24
while
(*
s
) {
25
b
=
mulf
(
a
,
10
);
26
c
=
addf
(
b
, *
s
-
'0'
);
27
mfree
(
a
);
28
mfree
(
b
);
29
a
=
c
;
30
s
++;
31
}
32
33
if
(!
MZERO
(
a
))
34
MSIGN
(
a
) *=
sign
;
35
36
return
a
;
37
}
38
39
static unsigned int
*
40
addf
(
unsigned int
*
a
,
int
n
)
41
{
42
unsigned int
*
b
, *
c
;
43
b
=
mint
(
n
);
44
c
=
madd
(
a
,
b
);
45
mfree
(
b
);
46
return
c
;
47
}
48
49
static unsigned int
*
50
mulf
(
unsigned int
*
a
,
int
n
)
51
{
52
unsigned int
*
b
, *
c
;
53
b
=
mint
(
n
);
54
c
=
mmul
(
a
,
b
);
55
mfree
(
b
);
56
return
c
;
57
}