@@ -67,7 +67,7 @@ struct Fp(uint size)
67
67
enum scale = T(2 ) ^^ T.mant_dig;
68
68
x = frexp(x, exp) * scale;
69
69
}
70
- auto dd = this .coefficient.view.leastSignificantFirst;
70
+
71
71
static if (T.mant_dig < 64 )
72
72
{
73
73
auto xx = cast (ulong )cast (long )x;
@@ -76,8 +76,12 @@ struct Fp(uint size)
76
76
auto shift = ctlz(xx);
77
77
exp -= shift + T.mant_dig + size - 64 ;
78
78
xx <<= shift;
79
+ this .coefficient = UInt! 64 (xx).rightExtend! (size - 64 );
80
+ }
81
+ else
82
+ {
83
+ this .coefficient = xx;
79
84
}
80
- dd[normalize ? $ - 1 : 0 ] = xx;
81
85
}
82
86
else
83
87
static if (T.mant_dig == 64 )
@@ -88,8 +92,12 @@ struct Fp(uint size)
88
92
auto shift = ctlz(xx);
89
93
exp -= shift + T.mant_dig + size - 64 ;
90
94
xx <<= shift;
95
+ this .coefficient = UInt! 64 (xx).rightExtend! (size - 64 );
96
+ }
97
+ else
98
+ {
99
+ this .coefficient = xx;
91
100
}
92
- dd[normalize ? $ - 1 : 0 ] = xx;
93
101
}
94
102
else
95
103
{
@@ -103,15 +111,22 @@ struct Fp(uint size)
103
111
x *= scale;
104
112
auto most = ulong (high);
105
113
auto least = cast (ulong )x;
114
+ version (LittleEndian )
115
+ ulong [2 ] pair = [most, least];
116
+ else
117
+ ulong [2 ] pair = [least, most];
106
118
107
- dd[normalize ? $ - 1 : 1 ] = most;
108
- dd[normalize ? $ - 2 : 0 ] = least;
109
119
if (normalize)
110
120
{
121
+ this .coefficient = UInt! 128 (pair).rightExtend! (size - 128 );
111
122
auto shift = most ? ctlz(most) : ctlz(least) + 64 ;
112
123
exp -= shift + T.mant_dig + size - 64 * (1 + (T.mant_dig > 64 ));
113
124
this .coefficient <<= shift;
114
125
}
126
+ else
127
+ {
128
+ this .coefficient = pair;
129
+ }
115
130
}
116
131
if (! normalize)
117
132
{
0 commit comments