gpt4 book ai didi

c - 为什么以 10 为底的 -9 等于以 17 为底的 a7ffda89?

转载 作者:太空宇宙 更新时间:2023-11-04 05:52:31 26 4
gpt4 key购买 nike

使用 Microsoft 的 itoa 实现,如何将“a7ffda89”作为基数 10 中 -9 的基数 17 表示?我正在寻找的是算法的描述。

这是我用来找出 itoa 使用 Microsoft 的实现会返回什么的代码:

#include "stdafx.h"  
#include <stdlib.h>

int main(int argc, char *argv[])
{
(void)argc;
(void)argv;
char buff[256] = {};
memset(buff, '0', 256);
_itoa_s(-9, buff, 256, 17);
exit(0);
}

最佳答案

来自 cplusplus.com :

If base is 10 and value is negative, the resulting string is preceded with a minus sign (-). With any other base, value is always considered unsigned.

关于c - 为什么以 10 为底的 -9 等于以 17 为底的 a7ffda89?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36380660/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com