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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
use crate::util::*;
#[cfg(feature = "correct")]
use super::shared::*;
perftools_inline!{
#[cfg(feature = "correct")]
pub(crate) fn standalone_mantissa<'a, T, Iter1, Iter2>(mut integer: Iter1, mut fraction: Iter2, radix: u32)
-> (T, usize)
where T: UnsignedInteger,
Iter1: Iterator<Item=&'a u8>,
Iter2: Iterator<Item=&'a u8>
{
let mut value: T = T::ZERO;
while let Some(c) = integer.next() {
value = match add_digit(value, to_digit!(*c, radix).unwrap(), radix) {
Some(v) => v,
None => {
let truncated = 1 + integer.count() + fraction.count();
return (value, truncated);
},
};
}
while let Some(c) = fraction.next() {
value = match add_digit(value, to_digit!(*c, radix).unwrap(), radix) {
Some(v) => v,
None => {
let truncated = 1 + fraction.count();
return (value, truncated);
},
};
}
(value, 0)
}}
perftools_inline!{
#[cfg(not(feature = "correct"))]
pub(crate) fn standalone_mantissa<'a, T, Iter>(mut iter: Iter, radix: u32)
-> T
where T: Integer,
Iter: Iterator<Item=&'a u8>
{
let mut value = T::ZERO;
while let Some(c) = iter.next() {
value = (value * as_cast(radix)) + as_cast(to_digit!(*c, radix).unwrap());
}
value
}}
perftools_inline!{
#[cfg(not(feature = "correct"))]
pub(crate) fn standalone_mantissa_n<'a, T, Iter>(iter: &mut Iter, radix: u32, max: usize)
-> (T, usize)
where T: Integer,
Iter: Iterator<Item=&'a u8>
{
let mut value = T::ZERO;
let mut index = 0;
while index < max {
if let Some(c) = iter.next() {
index += 1;
value = (value * as_cast(radix)) + as_cast(to_digit!(*c, radix).unwrap());
} else {
break;
}
}
(value, index)
}}