Zig 0.17.0-dev (Split by item) This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig standard library.
std › fmt › parse_float › decimal › Decimal › rightShift Public Function rightShift Doc Source Public Function std.fmt.parse_float.decimal.Decimal.rightShift
pub fn rightShift (self : *Self , shift : usize ) void Params File fmt/parse_float/decimal.zig: 186
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233 pub fn rightShift (self : *Self , shift : usize ) void {
var read_index : usize = 0 ;
var write_index : usize = 0 ;
var n : MantissaT = 0 ;
while (math .shr (MantissaT , n , shift ) == 0 ) {
if (read_index < self .num_digits ) {
n = (10 * n ) + self .digits [read_index ];
read_index += 1 ;
} else if (n == 0 ) {
return ;
} else {
while (math .shr (MantissaT , n , shift ) == 0 ) {
n *= 10 ;
read_index += 1 ;
}
break ;
}
}
self .decimal_point -= @as (i32 , @intCast (read_index )) - 1 ;
if (self .decimal_point < -decimal_point_range ) {
self .num_digits = 0 ;
self .decimal_point = 0 ;
self .truncated = false ;
return ;
}
const mask = math .shl (MantissaT , 1 , shift ) - 1 ;
while (read_index < self .num_digits ) {
const new_digit = @as (u8 , @intCast (math .shr (MantissaT , n , shift )));
n = (10 * (n & mask )) + self .digits [read_index ];
read_index += 1 ;
self .digits [write_index ] = new_digit ;
write_index += 1 ;
}
while (n > 0 ) {
const new_digit = @as (u8 , @intCast (math .shr (MantissaT , n , shift )));
n = 10 * (n & mask );
if (write_index < max_digits ) {
self .digits [write_index ] = new_digit ;
write_index += 1 ;
} else if (new_digit > 0 ) {
self .truncated = true ;
}
}
self .num_digits = write_index ;
self .trim ();
}
Computes decimal * 2^-shift.