普贤教程 › 包参考
numconv 包
数制转换
| 项 | 值 |
|---|---|
| 包名 | numconv |
| 版本 | 0.1.0 |
| 入口 | numconv.px |
| 分类 | 文本与中文处理 |
| 文件数 / 行数 | 1 / 197 |
安装与引入
bash
pxpkg init # 首次 pxpkg add numconv@0.1.0 pxpkg install
px
import numconv所属分类教程:文本与中文处理
公开接口
| 函数 | 参数 |
|---|---|
nc_to_base | n, base |
nc_from_base | s, base |
nc_base_convert | num, from_base, to_base |
nc_dec2bin | n |
nc_bin2dec | s |
nc_dec2hex | n |
nc_hex2dec | s |
nc_dec2oct | n |
nc_oct2dec | s |
nc_dec2roman | n |
nc_roman2dec | s |
nc_dec2words | n |
包内说明(源码头注释)
text
============================================================ 普贤生态库:registry/numconv — 数制转换 ------------------------------------------------------------ 纯函数库,双模式一致。 对齐 PHP base_convert / decbin / bindec / dechex / hexdec / decoct / octdec: nc_base_convert(num, from_base, to_base) → 任意进制转换 nc_to_base(n, base) → 整数→指定进制字符串 nc_from_base(s, base) → 指定进制字符串→整数 nc_dec2bin(n) / nc_bin2dec(s) nc_dec2hex(n) / nc_hex2dec(s) nc_dec2oct(n) / nc_oct2dec(s) nc_dec2roman(n) → 整数→罗马数字 nc_roman2dec(s) → 罗马数字→整数 nc_dec2words(n) → 英文数字单词(简易版) ============================================================