LMMP 4.3.0
Lamina High-Precision Arithmetic Library
载入中...
搜索中...
未找到
to_chars.c 文件参考
#include "lmmp/lmmpn.h"
to_chars.c 的引用(Include)关系图:

浏览该文件的源代码.

函数

void lmmp_b36_to_chars_ (mp_byte_t *dst, mp_size_t n, bool upper)
 36进制数字字节原地转字符 [dst,n]: [0,35] -> ['0'-'9','a'-'z']或['0'-'9','A'-'Z']
void lmmp_dec_to_chars_ (mp_byte_t *dst, mp_size_t n)
 Copyright (C) 2026 HJimmyK (Jericho Knox)

函数说明

◆ lmmp_b36_to_chars_()

void lmmp_b36_to_chars_ ( mp_byte_t * dst,
mp_size_t n,
bool upper )

36进制数字字节原地转字符 [dst,n]: [0,35] -> ['0'-'9','a'-'z']或['0'-'9','A'-'Z']

参数
dst输入数字字节数组,同时也是字符输出数组
n字节数组长度
upper大小写选择:true输出大写字母,false输出小写字母
警告
n>=0, dst!=NULL, 0<=dst[i]<=35
注解
原地操作,数值数组转化成字符串

在文件 to_chars.c 第 31 行定义.

31 {
32 // x>=10 时 c = x + '0' + adj, adj = 'a'-'0'-10 = 39 (小写) / 'A'-'0'-10 = 7 (大写)
33 // -(x>9) 生成全0/全1掩码,与 adj 按位与实现无分支选择
34 const int adj = upper ? 7 : 39;
35 for (mp_size_t i = 0; i < n; i++) {
36 int x = dst[i];
37 dst[i] = (mp_byte_t)(x + '0' + (-(x > 9) & adj));
38 }
39}
uint8_t mp_byte_t
定义 lmmp.h:91
uint64_t mp_size_t
定义 lmmp.h:93
#define n

引用了 lmmp_b36_to_chars_() , 以及 n.

被这些函数引用 lmmp_b36_to_chars_().

函数调用图:
这是这个函数的调用关系图:

◆ lmmp_dec_to_chars_()

void lmmp_dec_to_chars_ ( mp_byte_t * dst,
mp_size_t n )

Copyright (C) 2026 HJimmyK (Jericho Knox)

十进制数字字节原地转字符 [dst,n]: [0,9] -> ['0','9']

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

Copyright (C) 2026 HJimmyK (Jericho Knox)

参数
dst输入数字字节数组,同时也是字符输出数组
n字节数组长度
警告
n>=0, dst!=NULL, 0<=dst[i]<=9
注解
原地操作,数值数组转化成字符串

在文件 to_chars.c 第 26 行定义.

26 {
27 for (mp_size_t i = 0; i < n; i++)
28 dst[i] = (mp_byte_t)(dst[i] + (mp_byte_t)'0');
29}

引用了 lmmp_dec_to_chars_() , 以及 n.

被这些函数引用 check_decimal_one() , 以及 lmmp_dec_to_chars_().

函数调用图:
这是这个函数的调用关系图: