LMMP
4.3.0
Lamina High-Precision Arithmetic Library
Toggle main menu visibility
载入中...
搜索中...
未找到
to_hex.c
浏览该文件的文档.
1
/**
2
* Copyright (C) 2026 HJimmyK (Jericho Knox)
3
*
4
* This file is part of LMMP.
5
*
6
* LMMP is free software: you can redistribute it and/or modify it
7
* under the terms of the GNU Lesser General Public License as
8
* published by the Free Software Foundation; either version 3 of
9
* the License, or (at your option) any later version.
10
*
11
* This library is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU Lesser General Public License for more details.
15
*
16
* You should have received a copy of the GNU Lesser General Public
17
* License along with this library. If not, see
18
* <https://www.gnu.org/licenses/>.
19
*
20
* SPDX-License-Identifier: LGPL-3.0-or-later
21
*/
22
23
#include "
impl/str_conv.h
"
24
#include "mparam.h"
25
#include "
lmmp/lmmpn.h
"
26
27
28
mp_size_t
lmmp_to_hex_len_
(
mp_srcptr
numa,
mp_size_t
na) {
29
if
(numa) {
30
do
{
31
if
(na == 0)
32
return
0;
33
}
while
(numa[--na] == 0);
34
// na 现为最高非零 limb 下标
35
return
(
LIMB_BITS
* na +
lmmp_limb_bits_
(numa[na]) + 3) >> 2;
36
}
37
return
na << 4;
38
}
lmmp_limb_bits_
#define lmmp_limb_bits_
定义
inlines.h:164
mp_size_t
uint64_t mp_size_t
定义
lmmp.h:93
mp_srcptr
const mp_limb_t * mp_srcptr
定义
lmmp.h:97
LIMB_BITS
#define LIMB_BITS
定义
lmmp.h:102
lmmpn.h
lmmp_to_hex_len_
mp_size_t lmmp_to_hex_len_(mp_srcptr numa, mp_size_t na)
计算转换为十六进制字符串需要的缓冲区长度
定义
to_hex.c:28
str_conv.h
src
lmmp
lmmpn
to_hex.c
生成于
, 为 LMMP使用
1.18.0