【问题标题】:gmp_printf() - print in hexadecimal / base16gmp_printf() - 以十六进制/base16 打印
【发布时间】:2016-08-03 17:34:14
【问题描述】:

我正在尝试使用 gmp_printf() 以十六进制打印,但由于某种原因它不起作用/工作异常。

mpz_t B; //number of bytes
mpz_set_str(B,argv[2],0);
gmp_printf("%Zd",B);

工作正常。

尝试将其更改为:

gmp_printf("%#0xZd",B);

但是使用这个我会为相同的输入得到不同的输出:

input: 0x397a52dccd55d39823964ae25
output1: 0xa8392f80Zd
output2: 0xa1eca3b0Zd
desired output: 0x397a52dccd55d39823964ae25 

【问题讨论】:

    标签: c hex printf gmp


    【解决方案1】:

    你可能想要gmp_printf("%#Zx\n",B);。请切勿发布这样的随机行,只发布完整的程序(#include <gmp.h>mpz_init(B) 等)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-14
      • 1970-01-01
      • 1970-01-01
      • 2020-05-14
      相关资源
      最近更新 更多