【发布时间】:2011-04-17 06:34:14
【问题描述】:
仅使用以下库:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <unistd.h>
#include <math.h>
我需要一种将十进制转换为十六进制的有效方法:
int iteration (arguments...) {
//calculate the number of iterations for this function to do something
return iterations; //returns in decimal, e.g. 70
}
char hello = (iteration in hex);
(十六进制迭代)的代码是什么样的?
我有很多循环,所以会有很多转换为十六进制,效率越高越好(尽管我很确定有一个函数可以做到这一点)。
【问题讨论】:
-
你认为
hello的类型会是什么? -
我什至无法弄清楚您在阅读该内容时要做什么。
-
十六进制不是一种类型,它只是一种不同的计数方式,和/或一种格式化数字数据以供打印的方式。 46 十六进制 = 70 十进制。除非我错过了什么......
-
我很抱歉@Brain...这是一个深夜,我很紧张:(