LAMMP 4.2.0
Lamina High-Precision Arithmetic Library
载入中...
搜索中...
未找到
extract_bits.c 文件参考
+ extract_bits.c 的引用(Include)关系图:

浏览源代码.

函数

mp_bitcnt_t lmmp_extract_bits_ (mp_srcptr restrict num, mp_size_t n, mp_limb_t *restrict ext, int bits)
 Copyright (C) 2026 HJimmyK(Jericho Knox)
 

函数说明

◆ lmmp_extract_bits_()

mp_bitcnt_t lmmp_extract_bits_ ( mp_srcptr restrict  num,
mp_size_t  n,
mp_limb_t *restrict  ext,
int  bits 
)

Copyright (C) 2026 HJimmyK(Jericho Knox)

This file is part of LAMMP.

LAMMP is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This program is distributed WITHOUT ANY WARRANTY.

See https://www.gnu.org/licenses/.

在文件 extract_bits.c20 行定义.

20 {
23 if (n == 1) {
24 int lb = lmmp_limb_bits_(num[0]);
25 if (lb <= bits) {
26 *ext = num[0];
27 return 0;
28 } else {
29 *ext = num[0] >> (lb - bits);
30 return lb - bits;
31 }
32 } else {
33 int lb = lmmp_limb_bits_(num[n - 1]);
34 if (lb < bits) {
35 *ext = num[n - 1] << (bits - lb);
36 *ext |= num[n - 2] >> (LIMB_BITS - bits + lb);
37 return LIMB_BITS * (n - 1) - (bits - lb);
38 } else if (lb == bits) {
39 *ext = num[n - 1];
40 return LIMB_BITS * (n - 1);
41 } else {
42 *ext = num[n - 1] >> (lb - bits);
43 return LIMB_BITS * (n - 1) + (lb - bits);
44 }
45 }
46}
#define lmmp_limb_bits_
Definition inlines.h:162
#define LIMB_BITS
Definition lmmp.h:86
#define lmmp_param_assert(x)
Definition lmmp.h:401
#define n

引用了 LIMB_BITS, lmmp_limb_bits_, lmmp_param_assert , 以及 n.