LMMP 4.3.0
Lamina High-Precision Arithmetic Library
载入中...
搜索中...
未找到
extract_bits.c 文件参考
#include "lmmp/lmmpn.h"
#include "impl/inlines.h"
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 LMMP.

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

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library. If not, see https://www.gnu.org/licenses/.

SPDX-License-Identifier: LGPL-3.0-or-later

在文件 extract_bits.c 第 27 行定义.

27 {
28 lmmp_param_assert(bits <= LIMB_BITS && bits > 0);
29 lmmp_param_assert(num != NULL && ext != NULL);
31 if (n == 1) {
32 int lb = lmmp_limb_bits_(num[0]);
33 if (lb <= bits) {
34 *ext = num[0];
35 return 0;
36 } else {
37 *ext = num[0] >> (lb - bits);
38 return lb - bits;
39 }
40 } else {
41 int lb = lmmp_limb_bits_(num[n - 1]);
42 if (lb < bits) {
43 *ext = lb ? (num[n - 1] << (bits - lb)) : 0;
44 *ext |= num[n - 2] >> (LIMB_BITS - bits + lb);
45 return LIMB_BITS * (n - 1) - (bits - lb);
46 } else if (lb == bits) {
47 *ext = num[n - 1];
48 return LIMB_BITS * (n - 1);
49 } else {
50 *ext = num[n - 1] >> (lb - bits);
51 return LIMB_BITS * (n - 1) + (lb - bits);
52 }
53 }
54}
#define lmmp_limb_bits_
#define LIMB_BITS
定义 lmmp.h:102
#define lmmp_param_assert(x)
定义 lmmp.h:509
#define n

引用了 LIMB_BITS, lmmp_extract_bits_(), lmmp_limb_bits_, lmmp_param_assert, n , 以及 restrict.

函数调用图: